proxy_set_header Host $host;
在我的nginx.conf文件中的/ wordpress /位置下,我得到了工作的Wordpress网址,与从url中删除/ wordpress /的管理面板分开了,使得管理面板中的所有链接都无法正常工作。
如果我删除proxy_set_header Host $ host ;,我会得到不起作用的Wordpress网址,但会得到一个有效的管理面板。
我运行了一个Wordpress安装,其NextJs前端带有docker-compose和nginx反向代理。我需要工作的Wordpress网址和管理面板,因为我需要访问RSS提要(/ feed-url,当我执行proxy_set_header-thing时不起作用)。
location /wordpress/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://IP-TO-WORDPRESS:8000/;
# proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-Proto $scheme;
}
events {
worker_connections 1024;
# worker_processes and worker_connections allows you to
calculate maxclients value:
# max_clients = worker_processes * worker_connections
}
http{
server {
listen 80;
listen [::]:80 default_server ipv6only=on;
return 301 https://$host$request_uri;
}
# HTTPS ?~@~T proxy all requests to the Node app
server {
# Enable HTTP/2
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name SERVER-NAME.no;
# Use the Let?~@~Ys Encrypt certificates
ssl_certificate /etc/letsencrypt/live/SERVER-
NAME.no/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/SERVER-
NAME.no/privkey.pem;
# Include the SSL configuration from cipherli.st
include snippets/ssl-params.conf;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For
$proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://localhost:82/;
proxy_ssl_session_reuse off;
proxy_set_header Host $http_host;
proxy_cache_bypass $http_upgrade;
proxy_redirect off;
}
location = /wordpress {
return https://SERVER-NAME.no/NEXT-JS-BLOG-PAGE;
}
location /wordpress/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For
$proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://IP.TO-WORDPRESS:8000/;
# proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
}
我希望网址既可以在wordpress管理面板中使用,也可以在wordpress帖子和RSS供稿中使用。事实并非如此。
请帮助,因为我对此一无所知。
答案 0 :(得分:0)
发现问题出在Wordpress应用中,而不是Nginx配置中。事实证明,Wordpress有一个名为wp_admin_canonical_url()的东西,它除了设置siteurl和home之外,还设置URL。
请参见https://wordpress.stackexchange.com/questions/269798/wrong-wp-admin-url。