awsでhttps設定をすると、nginxでエラーが出る、起動したいです。
ruby on rails でアプリを作成し、
(下準備編)世界一丁寧なAWS解説。EC2を利用して、RailsアプリをAWSにあげるまで
を参考にデプロイしました
SSL設定をしたく
を参考に設定していきました。
ここまではできたのですが、
サイトがうまく表示されず、
原因を探していくと、nginxの設定ができてなかったと気付きました
【超丁寧】Rails4.2 + AWS + nginx でウェブアプリのproductionを http → https に移行させた方法
のコードを参考にnginx設定をし、
nginxを起動すると、エラーになってしましました。
$ sudo service nginx restart Redirecting to /bin/systemctl restart nginx.service Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
とターミナルに表示され、
$ systemctl status nginx.service ● nginx.service - The nginx HTTP and reverse proxy server Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled) Active: failed (Result: exit-code) since 木 2020-01-09 07:49:57 UTC; 5min ago Process: 2753 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS) Process: 2970 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=1/FAILURE) Process: 2969 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS) Main PID: 2756 (code=exited, status=0/SUCCESS)
となってしまい、解決策を検索しているのですが見つかりません
どなたか教えていただけますでしょうか。
/etc/nginx/nginx.confは
nginxconf
1user nginx; 2worker_processes auto; 3error_log /var/log/nginx/error.log; 4pid /run/nginx.pid; 5 6# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic. 7include /usr/share/nginx/modules/*.conf; 8 9events { 10 worker_connections 1024; 11} 12 13http { 14 log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 15 '$status $body_bytes_sent "$http_referer" ' 16 '"$http_user_agent" "$http_x_forwarded_for"'; 17 18 access_log /var/log/nginx/access.log main; 19 20 sendfile off; 21 tcp_nopush on; 22 tcp_nodelay on; 23 keepalive_timeout 65; 24 types_hash_max_size 2048; 25 26 include /etc/nginx/mime.types; 27 default_type application/octet-stream; 28 29 # Load modular configuration files from the /etc/nginx/conf.d directory. 30 # See http://nginx.org/en/docs/ngx_core_module.html#include 31 # for more information. 32 include /etc/nginx/conf.d/*.conf; 33 34 server { 35 listen 80; 36 proxy_set_header X-Forwarded-Proto $scheme; 37 if ( $http_x_forwarded_proto != 'https' ) { 38 return 301 https://$host$request_uri; 39 } 40 41 # Load configuration files for the default server block. 42 include /etc/nginx/default.d/*.conf; 43 44 location / { 45 } 46 47 error_page 404 /404.html; 48 location = /40x.html { 49 } 50 51 error_page 500 502 503 504 /50x.html; 52 location = /50x.html { 53 } 54 } 55 56 #httpsサーバー 57 server { 58 listen 443 ssl; 59 server_name ○○○○○○○○;#ドメイン名に修正 60 } 61 62 63
と書きました。
/etc/nginx/conf.d/○○○○○confの内容は
error_log /var/www/rails/○○○○/log/nginx.error.log; access_log /var/www/rails/○○○○/log/nginx.access.log; # max body size upstream app_server { # for UNIX domain socket setups server unix:/var/www/rails/○○○○/tmp/sockets/.unicorn.sock fail_timeout=0; #自分のアプリケーション名に変更 } server { listen 80; server_name 13.112.20.119 archibook.cloud; # nginx so increasing this is generally safe... keepalive_timeout 5; # path for static files root /var/www/rails/○○○○/public; # page cache loading try_files $uri/index.html $uri.html $uri @app; location @app { # HTTP headers 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; } # Rails error pages error_page 500 502 503 504 /500.html; location = /500.html { root /var/www/rails/○○○○/public; } }
回答3件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。