server { listen 443 ssl; http2 on; server_name ops.wbd-rd.nl; ssl_certificate /etc/letsencrypt/live/infra/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/infra/privkey.pem; location /oauth2/ { proxy_pass http://oauth2-proxy-portainer:4180; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Scheme $scheme; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Auth-Request-Redirect $request_uri; } location = /oauth2/auth { internal; proxy_pass http://oauth2-proxy-portainer:4180; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Scheme $scheme; proxy_set_header X-Original-URI $request_uri; proxy_set_header Content-Length ""; proxy_pass_request_body off; } location / { auth_request /oauth2/auth; error_page 401 = /oauth2/sign_in; auth_request_set $auth_cookie $upstream_http_set_cookie; add_header Set-Cookie $auth_cookie; auth_request_set $auth_user $upstream_http_x_auth_request_email; proxy_set_header X-Forwarded-User $auth_user; proxy_pass https://portainer:9443; proxy_ssl_verify off; 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; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } }