我有一个针对 apache wordpress 的 nginx 反向代理设置,效果很好。但是,根据位置需要重定向到失败的外部 url。请检查以下配置。这是一个有效的设置吗?
https://platform.com/ https://platform.com/- 这有效 - 任何后续的 wp 页面也有效
https://platform.com/pen https://platform.com/pen- 这需要重定向到https://abcdef.com https://abcdef.com- 这不起作用 - 404 页面加载错误 有帮助吗?
server {
listen 443 ssl default_server;
listen [::]:443 default_server;
server_name platform.com;
server_tokens off;
root /var/www/html/def/public/;
index index.php;
ssl on;
ssl_certificate /tmp/fgh.crt;
ssl_certificate_key /tmp/fgh.pem;
access_log /var/log/nginx/access2.log;
error_log /var/log/nginx/error2.log;
location / {
proxy_set_header X-Forwarded-Proto $scheme;
try_files $uri @apache;
}
location @apache {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:8080;
}
location ~[^?]*/$ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:8080;
}
location /pen {
proxy_pass https://abcdef.com;
}
}
将服务器名称(wordpress 站点)从 http 前缀更改为 www 前缀后,代理传递重新定向起作用了。必须将所有 http https 服务器块重定向到 nginx 配置中的 www 服务器块
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)