简体   繁体   English

反向代理背后的Symfony

[英]Symfony behind reverse proxy

We have a private network where we have our apps installed on Apache virtual host like: 我们有一个专用网络,其中,我们的应用程序安装在Apache虚拟主机上,例如:

http://extranet.domain.com or http://calendar.domain.com http://extranet.domain.comhttp://calendar.domain.com

Everything works fine. 一切正常。 Now we need to make one of these apps available from outside of our network. 现在,我们需要从网络外部使这些应用程序之一可用。

Our only machine with public access is the zimbra (mail) server... where I tried to configure a reverse proxy but it's not working... I added this to /etc/nginx/sites-enabled/default 我们唯一具有公共访问权限的计算机是zimbra(邮件)服务器...我尝试在其中配置反向代理,但是它不起作用...我将此添加到了/etc/nginx/sites-enabled/default

location /extranet/ {
   proxy_pass http://extranet.domain.com/;
   proxy_http_version 1.1;
   proxy_set_header Accept-Encoding "";
   proxy_set_header   X-Real-IP $remote_addr;
   proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
}

If I try the external URL from a external network like this: 如果我从这样的外部网络尝试外部URL:

http://zimbra.externaldomain.com/extranet/login

I can reach to the login page and login but after the redirect it losses the extranet part of the URL so it goes nowhere... the where I got is 我可以到达登录页面并登录,但是重定向后它丢失了URL的Extranet部分,因此它无处可去...我得到的是

http://zimbra.externaldomain.com/home

Instead of 代替

http://zimbra.externaldomain.com/extranet/home

Any help or clue? 任何帮助或线索?

Beware the trailing slash: proxy_pass http://extranet.domain.com/; 当心斜杠: proxy_pass http://extranet.domain.com/; , it is a valid URI. ,它是有效的URI。 So nginx will replace your matched request with this. 因此,nginx将以此替换您的匹配请求。

If your matched location is /extranet/ , and you pass it with a URI, like /extranet/someurl , the nginx proxy pass will replace the matched location with its own URI, in your case / . 如果匹配的位置是/extranet/ ,并且使用URI传递它(例如/extranet/someurl ,则nginx代理传递将用自己的URI替换匹配的位置(在您的情况下/

So, the route /extranet/someurl will become /someurl . 因此,路由/extranet/someurl将变为/someurl

For reference 以供参考

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM