Qqwy
How to configure Apache for Phoenix?
Hello everyone!
I am trying to configure apache so I can have my Phoenix-Elixir-application running on the same server as some other applications.
The basic request-passing works, but I am having problems with the websocket-connections:
<VirtualHost *:80>
DocumentRoot "/var/www/my_app"
ServerName my_app.tld
ServerAlias www.my_app.tld
LoadModule proxy_module modules/mod_proxy.so
ProxyRequests Off
ProxyPreserveHost On
ProxyPass "/" "ws://localhost:4096/" retry=0 timeout=5
ProxyPassReverse "/" "ws://localhost:4096/" my_app.tld
</VirtualHost>
However, this does not properly work. The websocket connections fail, with the following response in the browser console:
WebSocket connection to 'ws://my_app.tld/socket/websocket?vsn=2.0.0' failed: Error during WebSocket handshake: Unexpected response code: 400
I don’t know what went wrong, but also not how to debug this: Nothing can be found in the apache log, nor in the Phoenix application log.
Most Liked
grych
We just had the similar issue opened with Drab, please take a look. Guido resolved it himself, and also wrote the wiki page about it.
Qqwy
Thank you, @grych! The proposed solution there (to add first a set of aliases for /socket/ besides the global ones) indeed seem to work, although I still need to check if this will still allow the fallback behaviour (that uses long-polling rather than websockets for the channel-connections) to work, because my intuition tells me that maybe apache will now also redirect HTTP requests to /socket/ to a websocket connection.
Thanks! ![]()
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance










