Problems running the app

I have built the release for an app with Distillery but having problems running on the production server.Here’s the configuration fro /etc/nginx/sites-available/myapp

    upstream myapp {
    server 127.0.0.1:4000;
}
server{
    listen 80;
    server_name myapp.com;

    location / {
        try_files $uri @proxy;
    }

    location @proxy {
        include proxy_params;
        proxy_redirect off;
        proxy_pass http://myapp;
    }
}

myapp.com takes me to the the default nginx page but myapp.com:4000 shows the default page that I have configured for my phoenix app.

I don’t use nginx muchmyself, so am no expert on it, but location / is going to match http://myapp.com … and that is set to be served by nginx directly. Try getting replacing the location / block with the contents of the location @proxy block.

(I used haproxy myself for these things, so I apologize in advance if the above is not correct; working off of my poor memory of how nginx config works…)

1 Like

Thanks @aseigo …tried it …it didn’t work

The try_files inside the default location / block will see if a local filename exists, and if so serve it, else it falls back to the proxy, so that is fine.

Given that, the configuration looks correct on an immediate guess without seeing your error logs, given that your proxy_params config is correct (which is not shown either, but assuming it is defaulted). Nothing in your error logs? No file being hosted as a fallback? Etc…?

Also, what do you mean by default page? If no filename existed at the $URI and the proxy did not return a success then it should fail pretty hard since you did not add a =404 handler at the end or so. If you are getting a page it will be coming from somewhere…

thanks @OvermindDL1…I had a quick look at the log file and this is one of the lines in the log

bind() to 0.0.0.0:4000 failed

I am very new to hosting…never done it before…so sorry if I am not making sense

Huh, do you have a listen 4000 or some other form in one of your nginx config files anywhere? It should not be.

Still though, that does not explain why you are seeing a page when you load port 80. What is the page you are seeing? Is the link public? Can you take a screenshot?