PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, June 25, 2022

[FIXED] How to proxy applications with Nginx and Docker

 June 25, 2022     nginx, reverse-proxy, timeoutexception     No comments   

Issue

I get an 5#5: *23 upstream timed out (110: Connection timed out) while connecting to upstream, client: error with nginx.

I have read and applied the Nginx reverse proxy causing 504 Gateway Timeout question. However my case sligthly different, because I have three endpoint to proxy.

My nginx.conf:

worker_processes 1;

events { worker_connections 1024; }

http {

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

          location /api {
            proxy_set_header   X-Real-IP $remote_addr;
            proxy_set_header   Host      $http_host;
            proxy_http_version 1.1;
            proxy_set_header Connection "";
            proxy_pass "http://[hostip]:8080/api";
        }

          location /api/attendance {
            proxy_set_header   X-Real-IP $remote_addr;
            proxy_set_header   Host      $http_host;
            proxy_http_version 1.1;
            proxy_set_header Connection "";
            proxy_pass "http://[hostip]:8000/api";
      }

           location / {
            include /etc/nginx/mime.types;
            root /usr/share/nginx/html;
            index index.html index.htm;
            try_files $uri $uri/ /index.html =404;

            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_set_header Host $host;

                        proxy_read_timeout 3600s;
                        proxy_send_timeout 3600s;


        }
 error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/share/nginx/html;
        }


  }

}

My "/" and the application with port:8080 proxy as they are expected, however my application with port:8000 does not proxy, and get the above mentioned timeout exception. If I try to request the application with the port:8000, the application works as expected.

What could cause the above described timeout, and how I should change my conf file?


Solution

The problem was not a Nginx or Docker related problem. The port 8000 was not opened on the application droplet.



Answered By - GaborH
Answer Checked By - Robin (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing