Skip to content

Instantly share code, notes, and snippets.

@oko
Created October 9, 2013 16:51
Show Gist options
  • Save oko/6904431 to your computer and use it in GitHub Desktop.
Save oko/6904431 to your computer and use it in GitHub Desktop.
Apache-to-Nginx-to-uWSGI proxy configuration with path prefix

Apache

<LocationMatch "/theproxypath">
  ProxyPass http://[hostname]:[port]/theproxypath
  ProxyPassReverse http://[hostname]:[port]/theproxypath
</LocationMatch>

Nginx

server {
    listen       [port] default_server;
    server_name  [origin-hostname];
    location /go4ip {
        uwsgi_pass      127.0.0.1:9000;
        include         uwsgi_params;
        
        # Required if Nginx not proxying to Apache over HTTPS
        uwsgi_param     HTTPS on;
        uwsgi_param     UWSGI_SCHEME "https";
        uwsgi_param     HTTP_X_FORWARDED_PROTO "https";
        
        # Required if path prefix to root of app
        uwsgi_param     SCRIPT_NAME /theproxypath;
        uwsgi_modifier1 30;
        uwsgi_param     UWSGI_SCHEME $scheme;
        uwsgi_param     SERVER_SOFTWARE    nginx/$nginx_version;
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment