我想在mydomain.tld上运行一个正常的网站,但是目录mydomain.tld / ws应该redirect/代理到在127.0.0.1:8989上运行的本地websocket服务器。
这是我到目前为止:
<VirtualHost *:80> ServerAdmin webmaster@localhost ServerName mydomain.tld DocumentRoot /var/www/mydomain.tld/ ProxyPass /ws ws://127.0.0.1:8989/ ProxyPassReverse /ws ws://127.0.0.1:8989/ <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/mydomain.tld/> Options -Indexes +FollowSymLinks +MultiViews AllowOverride All Require all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/error.mydomain.tld.log CustomLog ${APACHE_LOG_DIR}/access.mydomain.tld.log combined </VirtualHost>
但是,正常的网站工作,但我不能连接到/ ws,因为我得到状态代码403禁止,虽然我收到正确的HTTP响应头X-Powered-By: Ratchet/0.3.4这是WebSocket服务器。
这是从CustomLog结合起来的:
someip - - [15/Apr/2016:08:59:31 +0200] "GET /ws HTTP/1.1" 500 668 "-" "-"
我在Ubuntu 14.04上运行Apache 2.4 – 我做错了什么?
UPDATE
试图添加一个子域,但仍然是相同的错误:
<VirtualHost *:80> ServerName ws.mydomain.tld ProxyPreserveHost On ProxyRequests Off ProxyPassReverse / ws://127.0.0.1:8989/ ProxyPass / ws://127.0.0.1:8989/ </VirtualHost>
你需要代理通过http://当你听80端口。
<VirtualHost *:80> ServerName ws.mydomain.tld ProxyPreserveHost On ProxyRequests Off ProxyPassReverse / http://127.0.0.1:8989/ ProxyPass / http://127.0.0.1:8989/ </VirtualHost>