我有一台运行nginx的服务器。可以根据路径路由到各种应用程序。
还有另一台运行apache的服务器。我需要在其上托管两个wordpress(main和blog),并从nginx对其进行基于路径的proxy_pass。
示例:
www.example.com -> nginx -> apache-server -> main.vhost
www.example.com/blog -> nginx -> apache-server -> blog.vhost
这就是我要实现的方式。
我使用将内部虚拟域传递给apache来创建反向代理配置。
主要配置
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
server_name_in_redirect off;
proxy_set_header Host "main.php.internal.example.com";
proxy_set_header Referer "http://main.php.internal.example.com";
proxy_pass http://10.0.1.6/;
proxy_redirect http:// https://;
proxy_redirect https://main.php.internal.example.com/ https://www.example.com/;
}
博客配置
location /blog {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
server_name_in_redirect off;
proxy_set_header Host "blog.php.internal.example.com";
proxy_set_header Referer "http://blog.php.internal.example.com";
proxy_pass http://10.0.1.6/;
proxy_redirect http:// https://;
proxy_redirect https://blog.php.internal.example.com/ https://www.example.com/blog;
}
它工作正常,但是当我去wordpress admin时,它在路由中使用了内部域。我该如何解决这个问题。