【发布时间】:2021-08-30 04:59:05
【问题描述】:
我正在尝试将我的 Laravel Websockets 应用程序部署为我的 Laravel 8 API 项目的一部分。一切都在本地运行,但部署后我无法连接到我网站域上的端口6001,这是一个子域。
我正在使用带有 Apache 的 Cent OS 8 服务器,并且已经在 https://api.example.com/ 上为我的网站打开了端口 80,为了让我在 https://site.example.com/ 上的网站,我继续创建了一个名为的子域https://api-socket.example.com/ 并且需要将其代理到端口6001。
我尝试将 Nginx 服务器的 config 替换为虚拟主机,但是当我重新启动 httpd 时,Cloudflare 出现 521 错误,我的配置是:
/etc/httpd/sites-available/api-socket.example.com.conf
<VirtualHost *:80>
ServerAdmin admin@example.com
ServerName api-socket.example.com
<Proxy *>
Require all granted
Allow from all
</Proxy>
SSLEngine on
SSLProxyEngine on
SSLProxyVerify none
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
SSLProxyCheckPeerExpire off
RewriteEngine on
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule .* wss://127.0.0.1:6001%{REQUEST_URI} [P]
ProxyPass / ws://127.0.0.1:6001
ProxyPassReverse / ws://127.0.0.1:6001
</VirtualHost>
我安装了 certbot,在生成 SSL 后,我得到了上述文件的 Let's Encrypt 变体,带有*:443,但随后我的网络服务器停止运行?
我在这里缺少什么来创建代理,以便当我转到 https://api-socket.example.com/ 时,它只是代理到在该端口上服务器的本地主机上运行的 Web 套接字服务器?
【问题讨论】:
-
这就是上述配置的目的,因此它存在于
api-socket.example.com上,因此它只用于套接字,这就是为什么它在 URL 中有6001,你有一些例子吗? -
您服务器上的 Apache 版本是多少?
-
@Haridarshan Apache 版本:
Apache/2.4.37 (centos),安装了 certbot 并使用 Cloudflare for SSL