簡體   English   中英

Nginx重定向到“ index.html”

[英]Nginx redirecting to “index.html”

我將nginx用作在Apache上運行的Wordpress實例前面的反向代理。 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;
}

有任何想法嗎?

使用return 301 https://$host$request_uri; 而不是rewrite ^/(.+) https://$host/$1 permanent;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM