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

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

$
0
0
Hi,

I'm trying to set up NGinx to act as a load balancer to a few endpoints. For example, https://nlb.com/portal will forward requests to https://p1.com:7443/arcgis or https://p2.esri.com:7443/arcgis and http://nlb.com/portal will forward requests to https://p1.esri.com:7080/arcgis or https://p2.esri.com:7080/arcgis. I'm finding that by adding the different location for the URI, the request actually goes to https://p1.esri.com/arcgis. It seems that by adding a location within proxy_pass, it sends the request to 80/443. By leaving off the /arcgis/ from proxy_pass, I could see about rewriting the URL, but I'm interested in why this doesn't work. My config file is pasted below:


#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 {
proxy_pass http://conHTTP/arcgis;
proxy_set_header X-Forwarded-Host nlb.com;
proxy_redirect /arcgis/ http://nlb.com/portal/;
}

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/ {
proxy_pass https://conHTTPS/arcgis/;
proxy_set_header X-Forwarded-Host nlb.com;
proxy_redirect https://conHTTPS/arcgis/ https://nlb.com/portal/;
}
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;
}
}

Thanks for any help.

Viewing all articles
Browse latest Browse all 4759

Trending Articles