Open up config/prod.secret.exs and you should find a section about “Using releases” with a configuration to set. Go ahead and uncomment that line or manually add the line below, adapted to your application names:
This only sets how you generate URLs using the path-helpers.
It will not affect on which port tthe cowboy will listten for requests.
Pleasee use netstat -lnpt | grep beam to see on which port the BEAM is listening, if at all. Also please check the already mentioned option for configuring the endpoint to be started at all.
You probably want to set http: [port: 4013] as your endpoint config to listen on 4013. Also, you probably do not want your URL to include the :port field, or generated links will circumvent the RP in front of it. You also do not want to have 127.0.0.1 as :host, as that willl generate URLs pointing you to your local machine, rather than the server.
That is not entirely true - I am guilty of writing code that uses this setting to determine certain base domains.
Which does not matter for nginx - it will only listen on ports you tell it to listen to, and that is the port you tell phoenix to listen to. I’d be extremely surprised if this was the root of the problem.
Don’t do this please unless you know what you are doing. Why would you want to tell nginx a port “the BEAM is listening” to? The prod config for your phoenix server should set the port, if you have to do a workaround like this, something is very, very wrong!
This is true as far as I know (not an nginx expert…) All I can tell you is that I am usually using the domain the app is hosted on as the :host option, so if you have a domain bara.com and a DNS entry to haha.bara.com try to change the :host to haha.bara.com.
Aggghhh, that was the first thing I did. I should probably say that I’m a hobbyist, having used Rails and Phoenix in the past for my business. I tend to learn ‘just what I need to’ to get a job done, so as far as netstat goes, I’d say I definitely don’t know what I’m doing
The Phoenix app in question is one that I updated from an earlier 1.3 app, following the guide to do so, but didn’t have any problems with it on my Centos server, but I’ve messed that server up the other day. I can’t build a release on it, so I started a new Ubuntu box because it’s packages seem to be more up to date wrt to Elixir.
I’ve taken a quick look around the base Hello app generated from scratch and there’s a few things which look new so I guess I’ve got some reading to do.
Yes, NGINX listens on ports it was told to listen to, and forward requests to phoenix, cowboy, beam, whomever it was configured to forward to. In this particulart case it was configured to forward localhost:4013, but phoenix wasn’t told to listen on that port.
So, indeed, it does matter. And phoenix not beeing available were NGinx expects it, is the root of the problem.
As I said, this is just to check if some BEAM process is listening at all on a TCP port. Of course, that might or might not be the web application we want to get up and running. But this is part of the tedious research whether the app is up and running as a server or not.
But, yes, we need to know both is the application running (can be verified by a remote console) and is it listening at all or even on the port we need it to listen on.
We now have verified, that the latter is not the case. Still it would be nice to know if its running at all.
Therefore I have to agree, not all questions asked from this thread have been answered.
For now, from all informations available in this thread we have to assume that the application is running, but not starting the HTTP server and therefore nginx can’t forward requests and replies with a 502.
Also we have to assume that even if the endpoint gets started, it doesn’t get started at the port we want it to have, as no port to listen on is specified in any of the configs we can see. I do not remember which port was used by default, but I’m pretty sure, it is not 4013, but 4013 is expected by nginx, so it will still reply with 502.
So, as already has been mentioned, adding not only the config line for starting the server at all, but also adding http: [port: 4013] to the endpoint config, would help.
Also port: 4013 should be removed from the :url endpoint config, as it will affect how URLs will be created. And as there is an nginx listen in front for RPing the traffic, it should be left empty, such that phoenix will use the default port for each schema when generating links.
On Ubuntu server, you could use htop which should show your app as (at least) one process. If it is not, then your app is probably not running. But once again, I don’t see how that gives you any information over your_app/bin/your_app remote_console