Skip to content

Document complete reverse proxy for individual container setup #32

Description

@mStirner
map $http_upgrade $connection_upgrade {
  default upgrade;
  ''      close;
}

server {

    listen 80 default_server;
    server_name 127.0.0.1 localhost ${NGINX_HOSTNAME};

    # remove server version
    server_tokens off;

    root /usr/share/nginx/html;

    autoindex off;  
    access_log off;  

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    location ~ /(api|auth)/(.*)$ {
        resolver ${RESOLVER};
        proxy_pass ${BACKEND_PROTOCOL}://${BACKEND_HOST}:${BACKEND_PORT}/$1/$2;
        proxy_http_version 1.1;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Connection $connection_upgrade;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }    

    location /admin {
        resolver ${RESOLVER};
        proxy_pass ${ADMIN_PROTOCOL}://${ADMIN_HOST}:${ADMIN_PORT};
        proxy_http_version 1.1;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Connection $connection_upgrade;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }    

    location / {
        resolver ${RESOLVER};
        proxy_pass ${FRONTEND_PROTOCOL}://${FRONTEND_HOST}:${FRONTEND_PORT};
        proxy_http_version 1.1;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Connection $connection_upgrade;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions