Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # configuration file /etc/nginx/nginx.conf:
- events {}
- error_log /var/log/nginx/error.log debug;
- http {
- map $http_x_proxy_port $proxy_port {
- default 80; # Default port if X-PROXY-PORT header is not set
- }
- log_format custom_debug 'Host: $host, Container: $container, Port: $proxy_port, Path: $uri, X-PROXY-PORT: $http_x_proxy_port';
- access_log /var/log/nginx/access.log custom_debug;
- server {
- listen 80;
- http2 on;
- server_name proxy;
- location / {
- root /usr/share/nginx/html;
- index index.html;
- proxy_set_header Host $host;
- proxy_set_header X-Real-IP $proxy_protocol_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- proxy_set_header X-Forwarded-Proto $scheme;
- }
- location ~ ^/proxy/([^/]+)(/.*)?$ {
- # Extract container name from the URL
- set $container $1;
- set $rest_of_path $2;
- # Proxy the request to the respective container and port
- proxy_pass http://$container:$proxy_port$rest_of_path;
- 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;
- # Additional proxy settings
- proxy_redirect off;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement