我使用下面的配置nginx的1.4.1:nginx的与代理斜线传球
server { listen 8000; server_name correct.name.gr; location /test/register { proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Server $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://127.0.0.1; } }
当用户访问次数http://correct.name.gr:8000/test/register/
它们应该被代理到它运行的Apache我想要做的就是端口80.
当我访问http://correct.name.gr:8000/test/register/
我得到正确的结果(index.php)。 当我访问http://correct.name.gr:8000/test/register/asd
时,我得到了正确的结果(来自apache的404)。 当我访问http://correct.name.gr:8000/test/asd
时,我得到正确的结果(来自nginx的404)。 当我访问http://correct.name.gr:8000/test/register123
时,我得到了正确的结果(来自apache的404)。
问题是当我访问http://correct.name.gr:8000/test/register
。我得到了一个301响应,我被重定向到http://localhost/test/register/
(注意最后的斜线,当然还有'localhost')!
我还没有做任何其他配置到Nginx的尾部斜线或类似的东西。你知道什么是问题吗?我想要http://correct.name.gr:8000/test/register
通过代理到apache正常工作(或者如果不可能,至少发出404错误而不是重定向到用户的本地主机)。
更新1:我想http://correct.name.gr:8000/test/register
从不同的计算机比昨天我有不良行为的一个..那么,它的工作:我刚刚说向我指出了正确的http://correct.name.gr:8000/test/register/
301响应!如何从一台计算机上工作而不是从另一台计算机上工作(我在两台计算机上使用相同的浏览器 - Chrome)?我明天再试一次,从第三个测试中看到行为。
谢谢!
不,我没有尝试,玩......我明天 - 但看看更新请 – Serafeim
只是为了避免任何浏览器缓存的副作用,我宁愿推荐测试这些重定向从壳上卷曲:“curl -IL http://correct.name.gr:8000/test/register” – vreen
是的,非常好的评论... Curl FTW! – Serafeim