当我访问https://mydomain/my-slug时-得到有效的200响应。 但是,当我访问http://mydomain/my-slug时-Nginx返回404。
这是我的Nginx配置:
# Map CloudFront Header to a variable
map $http_cloudfront_forwarded_proto $cloudfront_proto {
default "http";
https "https";
}
server {
listen 80;
listen 443;
server_name mysite.com;
root /var/www/wordpress;
index index.php;
location / {
set $redirect_to_https 0;
if ( $cloudfront_proto != 'https' ) {
set $redirect_to_https 1;
}
if ( $request_uri = '/health' ) {
set $redirect_to_https 0;
}
if ( $redirect_to_https = 1 ) {
# return 301 https://$host$request_uri;
}
# This is cool because no php is touched for static content.
# include the "?$args" part so non-default permalinks doesn't break when using query string
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri $uri/ /index.php?$args =404;
fastcgi_pass unix:/var/run/php/php5.6-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
include global/restrictions.conf;
include global/pagespeed.conf;
}
我在这里错过了什么配置? 出于当前问题调试的目的,已禁用了SSL重定向。