Discover Centmin Mod today
Register Now

Nginx Path based Routing in Nginx

Discussion in 'Nginx and PHP-FPM news & discussions' started by Pradeep Patra, Mar 14, 2020.

Tags:
  1. Pradeep Patra

    Pradeep Patra New Member

    3
    0
    1
    Mar 14, 2020
    Ratings:
    +0
    Local Time:
    3:14 AM
    Hi all,

    I am implementing a small application to test the path based routing functionality using nginx. My set up is something as below:

    User<URL in Chrome with https> ->AWS Route 53(DNS resolution) -> AWS NLB (443)-> nginx(implements path based routing to different backend EC2 instances)------->http(backend ec2 instances)

    SSL is terminated at the nginx. When I run directly this URL with https://<domain name>:6667 it works fine and page loads properly. But through nginx it doesnt work and I get the below error(https://<domain-URL>/rest/).

    might be temporarily down or it may have moved permanently to a new web address.
    ERR_RESPONSE_HEADERS_TRUNCATED

    upstream app1 {
    keepalive 16;
    server test1.example.com:6666 max_fails=2 fail_timeout=300s;server test2.example.com:6666 max_fails=2 fail_timeout=300s;
    }

    upstream app1_external {
    sticky name=srv_id expires=1h domain=<domain-Name> httponly secure path=/;
    keepalive 16;
    server test1.example.com:6667 max_fails=2 fail_timeout=300s;server test2.example.com:6667 max_fails=2 fail_timeout=300s;
    }


    server {
    listen 443 ssl;
    access_log /var/log/nginx/access.log main;
    # listen [::]:443 ssl proxy_protocol;
    server_name <NLB DNS> <nginx server DNS>
    ssl_certificate "/etc/ssl/nginx/server.crt";
    ssl_certificate_key "/etc/ssl/nginx/server.key";
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 30m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers EECDH+AESGCM:EDH+AESGCM;
    ssl_prefer_server_ciphers on;

    location / {
    proxy_pass https://app1/;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_protocol_addr;
    real_ip_header X-Real-IP;
    proxy_http_version 1.1;
    proxy_set_header Connection "";
    }

    location /rest/ {
    proxy_pass http://app1_external/;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $scheme;
    real_ip_header X-Real-IP;
    proxy_http_version 1.1;
    proxy_set_header Connection "";
    }

    }

    nginx version: nginx/1.13.5
    Can anyone help me in this regard how to fix this issue?

    Regards
    Pradeep
     
  2. eva2000

    eva2000 Administrator Staff Member

    44,417
    10,144
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,692
    Local Time:
    7:44 AM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    Are you using Centmin Mod LEMP stack's Nginx ? as Centmin Mod Nginx uses 1.17.x branch so wouldn't be using ancient 1.13.5 version. This forum is for Centmin Mod LEMP stack community support :)
     
  3. Pradeep Patra

    Pradeep Patra New Member

    3
    0
    1
    Mar 14, 2020
    Ratings:
    +0
    Local Time:
    3:14 AM
    I can update the nginx version to 1.17.x. If everything looks good and there are some bug fix between the 1.13.5 to 1.17.x. Could you please help if there are any clue of this error?
     
  4. eva2000

    eva2000 Administrator Staff Member

    44,417
    10,144
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,692
    Local Time:
    7:44 AM
    Nginx 1.17.x
    MariaDB 5.5/10.x