Ashenn
Ashenn

Reputation: 11

Nginx proxy server to another proxy server Gateway timeout

It's my first time deploying an application on a deployment environment so I am a complete beginner at this, I have an nginx proxy server (call it server1) on an instance with an exposed IP to the internet & it routes requests to another server on a different instance (call it server2) that hosts my Django application, the conf file for server1 goes like this :

`server{
    server_name _;
    location / {
            proxy_pass_header Authorization;
            proxy_pass http://10.156.0.4:80;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_http_version 1.1;
            proxy_set_header Connection “”;
            proxy_buffering off;
            client_max_body_size 0;
            proxy_read_timeout 36000s;
            proxy_redirect off;
    }

    listen 443 ssl;
    listen [::]:443 ssl;
    include snippets/self-signed.conf;
    include snippets/ssl-params.conf; }
server{
    listen 80;
    listen [::]:80;
    server_name _;

    return 302 https://35.246.244.220;}

and the second server:

server{
    listen 80;
    listen [::]:80;
    server_name _;

    location / {
            proxy_pass_header Authorization;
            proxy_pass http://10.156.0.4:8880;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_http_version 1.1;
            proxy_set_header Connection “”;
            proxy_buffering off;
            client_max_body_size 0;
            proxy_read_timeout 36000s;
            proxy_redirect off;
    }
    location /static/ {
             alias /opt/app/mydjangoapp/staticfiles/;
             autoindex off; }
    }

I am running my django application using this command python manage.py runserver 0.0.0.0:8880 & I also did collectstatic before running the application.

Everything works fine when i edit proxy_pass in server1 to http://10.156.0.4:8880 directly but i needed the second nginx server so i can serve the static files for my application.

I feel like I am doing something obviously wrong here, but for the life of me i can't figure it out.

Upvotes: 0

Views: 886

Answers (1)

Ashenn
Ashenn

Reputation: 11

I figured out the problem, there was a firewall rule between those two instances that didn't allow ingress or egress from port 80, only port 8880. Didn't think of this at all!

Upvotes: 1

Related Questions