Difference between revisions of "Nginx access gateway"
Jump to navigation
Jump to search
Line 1: | Line 1: | ||
+ | # NGINX Tiny access gateway | ||
+ | |||
+ | ## nginx.conf | ||
``` | ``` | ||
error_log /dev/stdout info; | error_log /dev/stdout info; | ||
Line 24: | Line 27: | ||
proxy_pass https://example.org; | proxy_pass https://example.org; | ||
− | |||
− | |||
− | |||
− | |||
− | |||
} | } | ||
} | } | ||
Line 34: | Line 32: | ||
``` | ``` | ||
+ | ## Run | ||
``` | ``` | ||
nginx -t $(pwd)/nginx.conf | nginx -t $(pwd)/nginx.conf | ||
nginx -c $(pwd)/nginx.conf | nginx -c $(pwd)/nginx.conf | ||
+ | ``` | ||
+ | |||
+ | |||
+ | # Note | ||
+ | ``` | ||
+ | # proxy_set_header Host $host; | ||
+ | # proxy_set_header X-Real-IP $remote_addr; | ||
+ | # proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
+ | # proxy_set_header X-Forwarded-Proto $scheme; | ||
``` | ``` |
Latest revision as of 18:45, 1 April 2024
NGINX Tiny access gateway
nginx.conf
error_log /dev/stdout info; # error_log stderr; worker_processes 1; daemon off; pid /tmp/nginx.pid; events { } http { access_log /dev/stdout; server { listen 18443; server_name example.org; location / { if ($arg_key != "foo"){ add_header Content-Type text/plain; return 401 'Access Denied'; } proxy_pass https://example.org; } } }
Run
nginx -t $(pwd)/nginx.conf nginx -c $(pwd)/nginx.conf
Note
# proxy_set_header Host $host; # proxy_set_header X-Real-IP $remote_addr; # proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # proxy_set_header X-Forwarded-Proto $scheme;