| 1 | server { |
| 2 | listen 127.0.0.1:{{ env "NOMAD_PORT_app_http" }}; |
| 3 | absolute_redirect off; |
| 4 | access_log off; |
| 5 | root /usr/share/nginx/html; |
| 6 | |
| 7 | location = /snow-health { proxy_pass http://unix:/socket/navidrome.sock:/ping; } |
| 8 | location /snow.oauth2/ { |
| 9 | proxy_set_header Host $host; |
| 10 | proxy_set_header X-Forwarded-Proto https; |
| 11 | proxy_pass http://{{ range nomadService 1 (env "NOMAD_ALLOC_ID") "AUTH_SERVICE" }}{{ .Address }}:{{ .Port }}{{ end }}; |
| 12 | } |
| 13 | location = /snow-auth { |
| 14 | internal; |
| 15 | proxy_pass http://{{ range nomadService 1 (env "NOMAD_ALLOC_ID") "AUTH_SERVICE" }}{{ .Address }}:{{ .Port }}{{ end }}/snow.oauth2/auth; |
| 16 | proxy_pass_request_body off; |
| 17 | proxy_set_header Content-Length ""; |
| 18 | proxy_set_header Host $host; |
| 19 | proxy_set_header X-Forwarded-Proto https; |
| 20 | proxy_set_header X-Forwarded-Uri $request_uri; |
| 21 | } |
| 22 | location = /snow-signin { |
| 23 | internal; |
| 24 | return 302 /snow.oauth2/start?rd=https://$host$request_uri; |
| 25 | } |
| 26 | location = /ping { |
| 27 | proxy_set_header Remote-User ""; |
| 28 | proxy_pass http://unix:/socket/navidrome.sock:; |
| 29 | } |
| 30 | location = /auth/login { |
| 31 | proxy_set_header Remote-User ""; |
| 32 | proxy_set_header X-Forwarded-For ""; |
| 33 | proxy_pass http://unix:/socket/navidrome.sock:; |
| 34 | } |
| 35 | location /rest/ { |
| 36 | proxy_set_header Remote-User ""; |
| 37 | proxy_set_header X-Forwarded-For ""; |
| 38 | proxy_pass http://unix:/socket/navidrome.sock:; |
| 39 | } |
| 40 | location = /snow-session { |
| 41 | auth_request /snow-auth; |
| 42 | auth_request_set $snow_user $upstream_http_x_auth_request_preferred_username; |
| 43 | proxy_set_header Remote-User $snow_user; |
| 44 | proxy_set_header X-Forwarded-For ""; |
| 45 | proxy_set_header X-Nd-Authorization ""; |
| 46 | proxy_set_header Authorization ""; |
| 47 | add_header Cache-Control "no-store" always; |
| 48 | proxy_pass http://unix:/socket/navidrome.sock:/app/; |
| 49 | } |
| 50 | location = /manage { return 308 /manage/; } |
| 51 | location = /app { return 308 /app/; } |
| 52 | location ~ ^/(app|manage|share)/ { |
| 53 | auth_request /snow-auth; |
| 54 | error_page 401 = /snow-signin; |
| 55 | auth_request_set $snow_user $upstream_http_x_auth_request_preferred_username; |
| 56 | proxy_set_header Remote-User $snow_user; |
| 57 | proxy_set_header X-Forwarded-For ""; |
| 58 | proxy_set_header X-Nd-Authorization ""; |
| 59 | proxy_set_header Authorization ""; |
| 60 | rewrite ^/manage/(.*)$ /app/$1 break; |
| 61 | proxy_pass http://unix:/socket/navidrome.sock:; |
| 62 | } |
| 63 | location /api/ { |
| 64 | auth_request /snow-auth; |
| 65 | error_page 401 = @native_api; |
| 66 | auth_request_set $snow_user $upstream_http_x_auth_request_preferred_username; |
| 67 | proxy_set_header Remote-User $snow_user; |
| 68 | proxy_set_header X-Forwarded-For ""; |
| 69 | proxy_set_header X-Nd-Authorization ""; |
| 70 | proxy_set_header Authorization ""; |
| 71 | proxy_pass http://unix:/socket/navidrome.sock:; |
| 72 | } |
| 73 | location @native_api { |
| 74 | proxy_set_header Remote-User ""; |
| 75 | proxy_set_header X-Forwarded-For ""; |
| 76 | proxy_pass http://unix:/socket/navidrome.sock:; |
| 77 | } |
| 78 | location = /settings.js { |
| 79 | auth_request /snow-auth; |
| 80 | alias /etc/nginx/conf.d/settings.js; |
| 81 | add_header Cache-Control "no-store"; |
| 82 | } |
| 83 | location / { |
| 84 | auth_request /snow-auth; |
| 85 | error_page 401 = /snow-signin; |
| 86 | sub_filter '<head>' '<head><script src="/snow-bootstrap.js"></script>'; |
| 87 | sub_filter 'type="module" crossorigin src=' 'type="application/x-snow-module" crossorigin src='; |
| 88 | sub_filter_once off; |
| 89 | try_files $uri $uri/ /index.html; |
| 90 | } |
| 91 | } |