Nginx reverse proxy with separate aliases
Posted
by
gabeDel
on Server Fault
See other posts from Server Fault
or by gabeDel
Published on 2012-06-24T08:08:48Z
Indexed on
2012/06/24
9:17 UTC
Read the original article
Hit count: 185
Interesting question I have this python code:
import sys, bottle, gevent
from bottle import *
from gevent import *
from gevent.wsgi import WSGIServer
@route("/")
def index():
yield "/"
application=bottle.default_app()
WSGIServer(('', port), application, spawn=None).serve_forever()
that runs standalone with nignx infront of it as a reverse proxy.
Now each of these pieces of code run separately but I run multiple of these per domain per project(directory) but the code thinks for some reason that it is top level and its not so when you go to mydomain.com/something it works but if you go to mydomain.com/something/ you will get an error. No I have tested and figured out that nginx is stripping the "something" from the request/query so that when you go to mydomain.com/something/ the code thinks you are going to mydomain.com// how do I get nginx to stop removing this information?
Nginx site code:
upstream mydomain {
server 127.0.0.1:10100 max_fails=5 fail_timeout=10s;
}
upstream subdirectory {
server 127.0.0.1:10199 max_fails=5 fail_timeout=10s;
}
server {
listen 80;
server_name mydomain.com;
access_log /var/log/nginx/access.log;
location /sub {
proxy_pass http://subdirectory/;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_max_temp_file_size 0;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
location /subdir {
proxy_pass http://subdirectory/;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_max_temp_file_size 0;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
}
© Server Fault or respective owner