Amy Murphy
Amy Murphy

Reputation: 1083

Nginx layer 7 request routing

So i am trying to do a routing to 3 differents containers based on the request using docker and Nginx. The containers have the same IP and different ports. here is the Nginx configuration :

upstream helpdesk{
    server 10.10.10.20:8089;
}

upstream dsi_helpdesk{
    server 10.10.10.20:8088;
}

upstream drh_helpdesk{
    server 10.10.10.20:8090;
}

server {

    listen       80;
    server_name  myticket.grgsh.com;


    location / {
        proxy_set_header Host $host;
        proxy_pass http://helpdesk;
    }

    location /dsi {
        proxy_set_header Host $host;
        proxy_pass http://dsi_helpdesk;
    }

    location /drh {
        proxy_set_header Host $host;
        proxy_pass http://drh_helpdesk;
    }

}

when i navigate to myticket.grgsh.com the server redirect me to the upstream helpdesk but when i navigate to myticket.grgsh.com/dsi or myticket.grgsh.com/drh i get the error :

Not Found The requested URL was not found on this server.

Can anyone help resolve this problem ? Thanks.

Upvotes: 0

Views: 186

Answers (2)

Amy Murphy
Amy Murphy

Reputation: 1083

After fixing the first problem, i got another one, so agter redirecting to myticket.grgsh.com/dsi, the web page that i get are without css or icons, here is the logs output:

 [29/Dec/2019:14:03:56 +0000] 10.1.12.142 - - - myticket.grgsh.com myticket.grgsh.com to:10.10.10.51:80: GET /dsi HTTP/1.1 200 upstream_response_time0.028 msec 1577628236.505 request_time 0.033
    10.1.12.142 - - [29/Dec/2019:14:03:56 +0000] "GET /css/styles.css HTTP/1.1" 404 196 "http://myticket.grgsh.com/dsi" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729)" "-"
    10.1.12.142 - - [29/Dec/2019:14:03:56 +0000] "GET /css/palettes/flood.min.css?v=9.3.1 HTTP/1.1" 404 196 "http://myticket.grgsh.com/dsi" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729)" "-"
    10.1.12.142 - - [29/Dec/2019:14:03:56 +0000] "GET /lib/font-awesome-4.7.0/css/font-awesome.min.css?v=9.3.1 HTTP/1.1" 404 196 "http://myticket.grgsh.com/dsi" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729)" "-"
    10.1.12.142 - - [29/Dec/2019:14:03:56 +0000] "GET /lib/jqueryplugins/select2/js/select2.full.js?v=9.3.1 HTTP/1.1" 404 196 "http://myticket.grgsh.com/dsi" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729)" "-"
    10.1.12.142 - - [29/Dec/2019:14:03:56 +0000] "GET /lib/jquery/js/jquery-1.10.2.min.js?v=9.3.1 HTTP/1.1" 404 196 "http://myticket.grgsh.com/dsi" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729)" "-"
    10.1.12.142 - - [29/Dec/2019:14:03:56 +0000] "GET /lib/jqueryplugins/select2/css/select2.min.css?v=9.3.1 HTTP/1.1" 404 196 "http://myticket.grgsh.com/dsi" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729)" "-"
    10.1.12.142 - - [29/Dec/2019:14:03:56 +0000] "GET /js/common.min.js?v=9.3.1 HTTP/1.1" 404 196 "http://myticket.grgsh.com/dsi" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729)" "-"
    10.1.12.142 - - [29/Dec/2019:14:03:56 +0000] "GET /front/cron.php HTTP/1.1" 404 196 "http://myticket.grgsh.com/dsi" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729)" "-"

Upvotes: 0

Amy Murphy
Amy Murphy

Reputation: 1083

The solution is:

This

location /dsi {
    proxy_set_header Host $host;
    proxy_pass http://dsi_helpdesk;
}

Needs to be this

location /dsi/ {
    proxy_set_header Host $host;
    proxy_pass http://dsi_helpdesk/;
}

Upvotes: 1

Related Questions