DEV Community

Discussion on: Nginx: Everything about proxy_pass

Collapse
 
iampeters profile image
Peters Chikezie

Hi Daniel,

It's a formating issue.

Thread Thread
 
danielkun profile image
Daniel Albuschat

Hm... looks correct, though. Maybe the error lies elsewhere?

Thread Thread
 
iampeters profile image
Peters Chikezie

Any idea where to look?

I have two sites enabled. The default nginx site running on port 80 and my API site running on a different port.

Thread Thread
 
danielkun profile image
Daniel Albuschat

Oh, then you forgot to provide the correct port in the URL. What you posted uses the default port 80, so it uses the default nginx site. Use http://127.0.0.1:<you-port>/foo/bar

Thread Thread
 
iampeters profile image
Peters Chikezie

I actually have the correct port in the file. The one I posted here is just an example. The IP is different

Thread Thread
 
iampeters profile image
Peters Chikezie • Edited

Hi Daniel,

Here is how the site looks

upstream backend {
 server 192.168.34.23:3000;
}
server {
        listen 5000 default_server;
        listen [::]:5000 default_server;

        root /var/www/html;
        index index.html index.htm index.nginx-debian.html;

        server_name http://example.com;

         location / {
                proxy_pass http://backend/;
                try_files $uri $uri/ =404;
        }
}
Thread Thread
 
iampeters profile image
Peters Chikezie

i am thinking, could the root there be the problem?

Thread Thread
 
iampeters profile image
Peters Chikezie

I have removed it and it's still the same thing.

Thread Thread
 
iampeters profile image
Peters Chikezie • Edited

Hi again Daniel,

I have been able to solve it.

I had to comment this line in the location

location / {
                proxy_pass http://backend/;
                #try_files $uri $uri/ =404;
        }

Thanks for your time. It's really appreciated