Welcome! Log In Create A New Profile

Advanced

Need help setting nginx up as proxy

January 11, 2010 06:17AM
I'm trying to setup nginx as a front-end receiving requests on port 80, and then forwarding them to another nginx installation listening on a different port.

The Nginx on port 80 is working okay, I opened up http://localhost/ and got the 'Welcome to Nginx' message.
The Nginx on port 7776 is working okay, I opened up http://static1.photosite.com:7776/js-min.js and got the page loaded okay.

But when I try to access the same address by port 80 (http://static1.photosite.com/js-min.js), instead of getting the page, I get 502 Bad Gateway.

The conf for Nginx on Port 80 is:
[code]
worker_processes 1;

pid /var/run/nginx.pid;


events {
worker_connections 1024;
}


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

sendfile on;

keepalive_timeout 65;

server {
listen 80;
server_name localhost;

location / {
root html;
index index.html index.htm;
}

# 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 80;
server_name www.photosite.com photosite.com static1.photosite.com static2.photosite.com;
location / {
proxy_pass http://127.0.0.1:7776;
}
}
}
[/code]






The conf for the Nginx on port 7776 is:
[code]
worker_processes 2;

pid logs/nginx.pid;

events {
worker_connections 1024;
}

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

server_names_hash_bucket_size 128;

sendfile on;
keepalive_timeout 10 10;

gzip on;
gzip_comp_level 3;
gzip_proxied any;
gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml application/xhtml+xml application/xml+rss text/javascript;
gzip_disable "MSIE [1-6]\.";

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

include sites/*;
}
[/code]





and relevant part of the site file included:
[code]
server {
listen 7776;
server_name static1.photosite.com static2.photosite.com;

error_log logs/photosite-static1-static2-error.log debug;
access_log logs/photosite-static1-static2-access.log main;

#Block access to dot files
location ^~ /. {
deny all;
}

#Fix IP address
set_real_ip_from 127.0.0.1;
real_ip_header X-Forwarded-For;

location / {
root /home/djeyewater/webapps/htdocs/photosite/CSI;
expires max;
}

location /Img/desktop {
add_header Content-Disposition: "$request_filename";
}
}
[/code]




Can anyone help me get this working?

Thanks

Dave
Subject Author Posted

Need help setting nginx up as proxy

djeyewater January 11, 2010 06:17AM

Re: Need help setting nginx up as proxy

djeyewater January 12, 2010 07:17AM

Re: Need help setting nginx up as proxy

merlin corey January 12, 2010 07:18PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 300
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready