server { listen 443 default_server ssl; listen [::]:443 default_server ssl; server_name galene.example.tld; ssl_certificate /etc/letsencrypt/live/galene.example.tld/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/galene.example.tld/privkey.pem; location /room/api { root /var/www/html; deny all; return 404; } location /room { root /var/www/html; auth_basic "Restricted Content"; auth_basic_user_file /etc/nginx/.htpasswd; location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php7.4-fpm.sock; } } location /api { root /var/www/html/room/; auth_basic "Restricted Content"; auth_basic_user_file /etc/nginx/.htpasswdapi; location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php7.4-fpm.sock; } } location / { # Force usage of https if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; } proxy_pass https://127.0.0.1:8443; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $server_name; # WebSocket support proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } }