Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
324 views
in Technique[技术] by (71.8m points)

Apache WebSocket only works on Reverse Proxy if included port number

I have an AngularJS with Spring REST MVC backend application. I'm trying to set up reverse proxy for the application, with the help of the proxy server admin. He got almost everything to work except for the websocket. The weird thing is if I added the port number to the reverse proxy URL, then websocket works too. For example:

https://proxy.example.com/myApp doesn't work with websocket. However, https://proxy.example.com:8443/myApp works with websocket.

I'm at a lost here. We've try many different things. Could you see what is missing in the configuration?

<VirtualHost *:443>
    ServerName proxy.example.com
    ServerAlias testServer
 
    SSLEngine on
    SSLProxyEngine on
    SSLCertificateFile /etc/ssl/certs/example.com_07012022.cer
    SSLCertificateKeyFile /etc/ssl/certs/example.com_07012022.pem
 
    ProxyPass / https://proxy.example.com:8443/
    ProxyPassReverse / https://proxy.example.com:8443/
 
    RewriteEngine on
    RewriteCond %{HTTP:Upgrade} websocket [NC]
    RewriteCond %{HTTP:Connection} upgrade [NC]
    RewriteRule .* "wss://proxy.example.com:8443/$1" [P,L]
</VirtualHost>

The ProxyPass and ProxyPassReverse doesn't look right, but I couldn't even hit the homepage with the following config:

ProxyPass / https://localhost:8443/
ProxyPassReverse / https://localhost:8443/

Thanks. Appreciate the help.

question from:https://stackoverflow.com/questions/65852939/apache-websocket-only-works-on-reverse-proxy-if-included-port-number

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...