Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

Re: Issue with proxy_pass, request URI's, and upstream servers

$
0
0
Hm, bear with me while I recap the behavior I see. So this is the new config:

#user nobody;
worker_processes 1;

error_log logs/error.log;
error_log logs/error.log notice;
error_log logs/error.log info;

#pid logs/nginx.pid;


events {
worker_connections 1024;
}


http {
include mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log logs/access.log main;

sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 65;

#gzip on;

upstream conHTTP {
server p1.com:7080;
server p2.com:7080;
}

upstream conHTTPS {
server p1.com:7443;
server p2.com:7443;
}

server {
listen 80;
server_name nlb.com;

location /portal {
rewrite /portal/([^/]+) /arcgis/$1 break;
proxy_pass http://conHTTP;
proxy_set_header X-Forwarded-Host nlb.com;
}

error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}

server {
listen 443 ssl;
server_name nlb.com;

ssl_certificate nlb.cer;
ssl_certificate_key nlb.key;

ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;

location /portal {
rewrite /portal/([^/]+) /arcgis/$1 break;
proxy_pass https://conHTTPS;
proxy_set_header X-Forwarded-Host nlb.com;
}
error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}}

When I make a request to nlb.com:

GET /portal/home/ HTTP/1.1
Host: nlb.com
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.94 Safari/537.36
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8

The response returns:

HTTP/1.1 302 Found
Server: nginx/1.9.15
Date: Wed, 04 May 2016 15:30:01 GMT
Location: https://nlb.com/arcgis/home/
Transfer-Encoding: chunked
Connection: keep-alive

Which sends the next request to the URI Location header:

GET /arcgis/home/ HTTP/1.1
Host: dev001316.esri.com
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.94 Safari/537.36
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8

Which returns a 404

HTTP/1.1 404 Not Found
Server: nginx/1.9.15
Date: Wed, 04 May 2016 15:30:01 GMT
Content-Type: text/html
Content-Length: 571
Connection: keep-alive

The Nginx error logs show an error reaching the arcgis/home page on it's on machine instead of the backend servers:

2016/05/04 08:30:42 [error] 4844#3052: *421 "C:\nginx-1.9.15/html/arcgis/home/index.html" is not found (3: The system cannot find the path specified), client: 10.29.78.47, server: nlb.com, request: "GET /arcgis/home/ HTTP/1.1", host: "nlb.com"

I tried to add a proxy_redirect:

proxy_redirect https://nlb.com/arcgis/ https://nlb.com/portal/;

But that had a worse effect. When I make a request to https://nlb.com/portal/home/:

GET /portal/home/ HTTP/1.1
Host: nlb.com
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.94 Safari/537.36
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8

It gets redirected to https://conhttps/arcgis/home/

HTTP/1.1 302 Found
Server: nginx/1.9.15
Date: Wed, 04 May 2016 15:40:35 GMT
Transfer-Encoding: chunked
Connection: keep-alive
Location: https://conHTTPS/arcgis/home/

Any ideas?

Viewing all articles
Browse latest Browse all 4759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>