nginx反向代理apache2网站:url返回与代理服务器不对应
问题描述:
我正在寻找一些提示如何做我目前想做的事情。nginx反向代理apache2网站:url返回与代理服务器不对应
这里就是我该做的: 的Nginx服务器代理(srvrp) - >的Apache2(srvdeba)
这里是nginx的网站srvrp的配置:
server {
server_name www.egloff-j-quest-etna.nx;
location/{
proxy_pass http://srvdeba.egloff-j-quest-etna.nx;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $proxy_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
}
}
这里是配置在srvdeba启用站点的网站:
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName www.srvdeba.egloff-j-quest-etna.nx
ServerAlias *srvdeba.egloff-j-quest-etna.nx
DocumentRoot /opt/wordpress
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /opt/wordpress/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
目前,这是工作,但不完全,问题如下: 当该网站是通过代理服务器加载,网站上所有的链接都是这种形式: http://srvdeba.egloff-j-quest-etna.nx 我希望他们对应: www.egloff-J-追求-etna.nx
于是,我想到了有两种解决方案,第一种解决方案是使用ngx_http_sub_module ,第二种解决方案是配置apache2,以便他知道他正在被代理,并且可以在通过代理服务器完成请求时重写URL。 srvdeba必须在没有代理服务器的情况下访问时才能工作。 所以我需要你告诉我什么是最好的解决方案!
在此先感谢您的答案。
答
所以,我很久以前终于找到了这个问题的答案。 我认为我最好把它分享给你。
问题不是来自Apache或nginx。 问题来自网站生成错误的URL,因为他不知道他是代理。 因此,如果你有类似的问题,你应该确保该网站知道他正在被代理并生成正确的URL来为客户端请求工作。
那么,我试过ngx_http_sub_module,它根本不工作。也许我做了一些错误的事情。现在我将尝试配置apache2。 – laxa 2014-10-11 15:29:56