[英]Configure NGINX Reverse Proxy in front of Apache Web Server
So I started using Ratchet (library to program and use a websocket server in PHP, http://socketo.me/docs/hello-world ) to program a chat application on my website (on the web server itself).
我将其全部设置在我的本地主机上,并且一切正常。 现在我想将它部署在我的 web 服务器上,这是一个 Apache 服务器。 For this to work, I apparently need to configure a reverse proxy, ideally with NGINX, in front of my web server, because the websocket server cannot simply listen on the same port as my Apache server.
When searching for sources which explain how to configure a reverse proxy with NGINX in front of my Apache web server, search results / articles / tutorials always tell me how to configure a reverse proxy using NGINX on an Apache WebServer ON UBUNTU. 我很困惑为什么 Ubuntu 总是在这里发挥作用; isn't it simply possible to configure an NGINX reverse proxy in front of my Apache web server, without the use of Ubuntu?
更新
我的服务器是基于共享主机的 web 服务器,我没有 root 访问权限。 那么实际上是否可以在我的 web 服务器前面放置一个反向代理,因为我什至无法更改我的 web 服务器监听的端口......?
可以更好地描述我想要的内容:我网站的特定页面应从 web 服务器加载其内容(html 结构,表示聊天窗口),但其聊天功能在服务器上显示为 PHP Ratchet 脚本 -侧,应通过 WebSocket 连接工作。 In other words, for this page, Web Server and WebSocket connections should work simultaneously, while I have only one Apache server, on a shared hosting basis, with no root access, on which both the chat application programmed in Ratchet and the website's HTML page存在(至少在我的本地主机上,这非常好用)。 考虑到我的托管条件,这甚至可以部署,还是我需要切换到另一种托管类型?
另外,请不要认为这个问题特定于 nginx。 根据 Ratchet 中的文档,我的解决方案是:
在同一台机器上运行 web 站点和 WebSocket 服务器,为 WebSockets 使用端口 8080,并抓住机会客户端代理不会阻塞流量
在自己的服务器上运行 WebSocket 服务器在子域 (sock.example.com) 下的端口 80 上
在您的 web 服务器和 WebSocket 服务器前面放置一个反向代理(Nginx、HAProxy、Varnish)
我也想通了(github)
我很高兴知道这四种或其他推荐解决方案中的任何一种,即使这不包括 nginx。
在更新部分之后:我们假设您不能在托管解决方案本身的托管解决方案前面放置反向代理。 这似乎不太可能。
我最好的选择是在专用 VPS 上设置反向代理,并通过它传递你的所有流量,但这种设置比你可能需要的要复杂得多。
从行“[...] 在我的 web 服务器上,这是一个 Apache 服务器。” 我猜您正在使用互惠托管解决方案。 在这种情况下,它将在很大程度上取决于您使用的特定主机。 在您的 CPanel 中尝试查找“反向代理”/“代理”/“套接字”/“网络套接字”参数。
如果您在 VPS 上托管,并且您将“家族”的 linux 分发为 ubuntu,请按照教程进行操作,它可能会起作用。 否则,请查找特定于您的发行版(或操作系统,如果您不在 linux 上)的教程。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.