現在AWSでEC2+RDS、rails+nginx+unicornでアプリを運用しておりますが、ElasticIPでアクセスできません。
しかしElasticIP:3000では問題なくアクセスでき、RDSの方にもデータがきちんと入ります。
この違いはどのようなことなのでしょうか。
このままElasticIP:3000で運用していても問題はないのでしょうか。
特に問題が内容でしたら、このまま運用しようと思うのですが。
ちなみにproduction.logのエラーコードはこのような感じです。
ActionController::RoutingError (No route matches [GET] "/favicon.ico"):
追記です。
大変申し訳ありません。
改行したものを追記いたします。
以下同じ内容です。
ご覧いただきまして、ありがとうございます。
説明不足で申し訳ございません。
セキュリティグループや各種設定は問題ないと存じます。
現状はポート80の時にCSSとjsが反映されない状況です。
3000番ポートの時はcssやjsも正常に表示されます。
先日までポート80でもきちんとCSSが反映されておりましたが、unicornの設定の不具合で色々と作業を行ううちに、反映されなくなってしまいました。
おそらくnginxが導入されていない状態なのかと思うのですが、実際はインストールされております。
nginxを認識させるために試したこと:
sudo service nginx stop
sudo service nginx start
sudo yum remove nginx
sudo yum install nginx
現状のnginxの設定ファイルは以下の通りです。
●/etc/nginx/conf.d/app.conf
upstream app_server{
server 127.0.0.1:3000;
}
server {
listen 80;
server_name xxx.xxx.xxx.xxx;
root /var/www/my_app/public;
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
try_files $uri/index.html $uri @unicorn;
location @unicorn {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://app_server;
}
error_page 500 502 503 504 /500.html;
}
●/etc/nginx/nginx.conf
///////////////////コメントアウト//////////////////
For more information on configuration, see:
* Official English Documentation: http://nginx.org/en/docs/
* Official Russian Documentation: http://nginx.org/ru/docs/
///////////////////コメントアウト//////////////////
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
///////////////////コメントアウト//////////////////
Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
///////////////////コメントアウト//////////////////
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream;
///////////////////コメントアウト//////////////////
Load modular configuration files from the /etc/nginx/conf.d directory.
See http://nginx.org/en/docs/ngx_core_module.html include
for more information.
///////////////////コメントアウト//////////////////
include /etc/nginx/conf.d/*.conf; index index.html index.htm;
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name localhost;
root /usr/share/nginx/html;
///////////////////コメントアウト//////////////////
Load configuration files for the default server block.
///////////////////コメントアウト//////////////////
include /etc/nginx/default.d/*.conf; location / { }
///////////////////コメントアウト//////////////////
redirect server error pages to the static page /40x.html
///////////////////コメントアウト//////////////////
error_page 404 /404.html; location = /40x.html { }
///////////////////コメントアウト//////////////////
redirect server error pages to the static page /50x.html
///////////////////コメントアウト//////////////////
error_page 500 502 503 504 /50x.html; location = /50x.html { }
///////////////////コメントアウト//////////////////
proxy the PHP scripts to Apache listening on 127.0.0.1:80
location ~ .php$ {
proxy_pass http://127.0.0.1;
}
pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 location ~ .php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; include fastcgi_params; } deny access to .htaccess files, if Apache's document root concurs with nginx's one location ~ /.ht { deny all; }
///////////////////コメントアウト//////////////////
}
///////////////////コメントアウト//////////////////
Settings for a TLS enabled server.
server {
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
server_name _;
root /usr/share/nginx/html;
ssl_certificate "/etc/pki/nginx/server.crt";
ssl_certificate_key "/etc/pki/nginx/private/server.key";
It is strongly recommended to generate unique DH parameters
Generate them with: openssl dhparam -out /etc/pki/nginx/dhparams.pem 2048
ssl_dhparam "/etc/pki/nginx/dhparams.pem";
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:SEED:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!RSAPSK:!aDH:!aECDH:!EDH-DSS-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA:!SRP;
ssl_prefer_server_ciphers on;
Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
///////////////////コメントアウト//////////////////
}
nginxはアンインストール後にインストールし直しましたが、conf.d/nginx.confはアンインストール前の記述が残っておりました。
アンインストールする場合は、confファイルも別にrmで削除したほうが良いのでしょうか。
nginxのファイルがどのディレクトリにどのように入っているのかわからず、上記のようにいたしました。
何かお気付きになる点などがございましたら、ぜひご教授くださいませ。
よろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー