ctarbide / nginx-user-unix-socket

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Why? Nginx is powerful and handy, with some tweaks, it can be used as
a personal webserver that is trivial to integrate using unix sockets
with a main nginx.

First of all, do, as 'root':

    su -c 'gpasswd -a '"${USER}"' nginx'

    # command above assumes nginx workers are running
    # under 'nginx' user

Then log off and log on.

The main nginx configuration should work with a snippet like:

    location ~ /test/ {
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_pass http://unix:/tmp/nginx-1000.socket;
    }

    location ~ /test$ {
        rewrite ^(.*)$ $1/ permanent;
    }

Exposing the socket with socat, for testing:

    socat tcp-l:3307,reuseaddr,fork,bind=127.0.0.1 unix:/tmp/nginx-1000.socket

Then just browse to http://127.0.0.1:3307/ and
http://127.0.0.1:3307/test/.


****************

For those in jurisdictions that recognize the public domain,
nginx-user-unix-socket is placed into the public domain.

For those in jurisdictions that do not recognize the public domain,
nginx-user-unix-socket is released under the ISC License.

See LICENSE for a copy of the ISC license.

Legalese taken from https://github.com/ibara/vce, many thanks to Brian
Callahan.

About

License:ISC License


Languages

Language:Shell 64.1%Language:M4 31.6%Language:HTML 4.3%