シンジです。シンジは限界を迎えました。すだちブログをELB配下にしたいのですが、InServiceになりません。いや、いまのままだとInServiceになるのですが、nginxのconfを下記のようにするとダメになります。何がおかしいか教えてください神様。。。
アクセスはHTTPSのみなので
ELBに証明書渡して、そこからEC2には80で渡してます。http80のアクセスはhttps443に飛ばしたいわけです。
default.conf
server { listen 80 default_server; server_name _; root /var/www/vhosts/hogehoge; index index.html index.htm; charset utf-8; access_log /var/log/nginx/hogehoge_access.log main; error_log /var/log/nginx/hogehoge_error.log; include /etc/nginx/drop; rewrite /wp-admin$ $scheme://$host$uri/ permanent; set $mobile ''; set $do_not_cache 0; if ($http_cookie ~* "comment_author_|wordpress_(?!test_cookie)|wp-postpass_" ) { set $do_not_cache 1; } if ($request_method != GET) { set $do_not_cache 1; } location /health_check { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; proxy_next_upstream error; proxy_pass https://blog.animereview.jp; break; } location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; proxy_next_upstream error; if ($http_x_forwarded_proto != "https") { rewrite ^(.*)$ https://$server_name$1 permanent; } proxy_pass https://blog.animereview.jp; add_header Strict-Transport-Security "max-age=31536000; includeSubDomains;"; } try_files $uri @wordpress; location ~ \.php$ { try_files $uri @wordpress; include /etc/nginx/php-fpm; } location @wordpress { internal; proxy_no_cache $do_not_cache; proxy_cache_bypass $do_not_cache; proxy_redirect off; proxy_cache czone; proxy_cache_key "$scheme://$host$request_uri$mobile"; proxy_cache_valid 200 0m; proxy_pass http://backend; } location = /wp-admin/install.php { set $script_root '/opt/local/amimoto'; if ( -e /opt/local/amimoto/.valid.$server_name ) { set $script_root $document_root; } if ( !-e /opt/local/amimoto/$fastcgi_script_name ) { set $script_root $document_root; } expires off; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass phpfpm; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $script_root$fastcgi_script_name; include fastcgi_params; } location = /wp-admin/setup-config.php { set $script '/opt/local/amimoto/wp-admin/install.php'; if ( -e /opt/local/amimoto/.valid.$server_name ) { set $script $document_root$fastcgi_script_name; } if ( !-e $script ) { set $script $document_root$fastcgi_script_name; } expires off; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass phpfpm; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $script; include fastcgi_params; } location ~* /(phpmyadmin|myadmin|pma) { access_log off; log_not_found off; return 404; } error_page 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } # nginx_status Enabled location /nginx_status { stub_status on; access_log off; allow 127.0.0.1; deny all; } }
今はEIPでEC2なので
もっと単純なconfで動かしてます。これそのままELBに持って行くと、リダイレクトループです。ってかコメント少なすぎconfでマジすみません。
ああ、これが完成すれば、シンジの考える最強のWordpressが完成しそうなのに。。。助けてください。。。