Nginx 重定向到 "index.html"

Nginx redirecting to "index.html"

我在 Apache 上的 Wordpress 实例 运行 前使用 nginx 作为反向代理。 HTTP 到 HTTPS 重定向是在 nginx 配置中实现的。

可惜http://example.org is redirecting to https://example.org/index.html instead of 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/ 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;
}

有什么想法吗?

使用return 301 https://$host$request_uri;代替rewrite ^/(.+) https://$host/ permanent;