我在Apache上运行的Wordpress实例前面使用nginx作为反向代理。 HTTP到HTTPS重定向是在nginx配置中实现的。
不幸的是, http://example.org 重定向到 https://example.org/index.html 而不是https://example.org
这是基本配置:
proxy_cache_path /data/nginx/cache levels=1:2 keys_zone=STATIC:10m
inactive=24h max_size=1g;
server {
listen 80 default deferred;
server_name example.com staging.example.com;
rewrite ^/(.+) https://$host/$1 permanent;
}
server {
listen 443 ssl;
server_name example.com staging.example.com;
index index.php;
root /;
ssl on;
ssl_certificate /etc/nginx/ssl/nginx.crt;
ssl_certificate_key /etc/nginx/ssl/nginx.key;
location / {
proxy_pass_header Server;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_connect_timeout 10;
proxy_read_timeout 10;
proxy_pass http://example-wordpress:80;
proxy_cache STATIC;
proxy_cache_valid 200 1d;
proxy_cache_use_stale error timeout invalid_header updating
http_500 http_502 http_503 http_504;
}
error_page 500 502 503 504 /media/50x.html;
}
有什么想法吗?
答案 0 :(得分:1)
使用return 301 https://$host$request_uri;
代替rewrite ^/(.+) https://$host/$1 permanent;