Qqwy

Qqwy

TypeCheck Core Team

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

grych

Creator of Drab

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

Qqwy

TypeCheck Core Team

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! :heart:

Where Next?

Popular in Questions Top

marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
Lily
In templates/appointment/index.html.eex: &lt;%= for appointment &lt;- @appointments do %&gt; &lt;tr&gt; &lt;td&gt;&lt;%= appoi...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
jaysoifer
Is there a way to rollback a specific migration and only that one (“skipping” all the other ones)? Would mix ecto.rollback -v 200809061...
New
earth10
Hi, I’m just starting to build a side-project with Elixir and Phoenix and doing some basic test with Elixir alone. What strikes me is th...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

Other popular topics Top

aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
New
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a &gt; b) do {:ok, "a"} end if (a &lt; b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 39467 209
New
boundedvariable
I am going through the kafka architecture. All the features what the kafka is providing are already in Erlang. I would like hear your opi...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 54120 245
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement