nginx.conf 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. worker_processes auto;
  2. pid /tmp/nginx.pid;
  3. error_log /dev/stderr info;
  4. events {
  5. worker_connections 1024;
  6. }
  7. http {
  8. include /etc/nginx/mime.types;
  9. default_type application/octet-stream;
  10. access_log /dev/stdout;
  11. sendfile on;
  12. tcp_nopush on;
  13. client_body_temp_path /tmp/nginx/client_body;
  14. proxy_temp_path /tmp/nginx/proxy;
  15. map $http_upgrade $connection_upgrade {
  16. default upgrade;
  17. '' close;
  18. }
  19. map $http_upgrade $is_websocket {
  20. default 1;
  21. '' 0;
  22. }
  23. server {
  24. listen 8080;
  25. server_name _;
  26. root /opt/selkies-web;
  27. index index.html;
  28. auth_basic "Selkies";
  29. auth_basic_user_file /tmp/selkies.htpasswd;
  30. location / {
  31. error_page 418 = @selkies_websocket;
  32. if ($is_websocket) {
  33. return 418;
  34. }
  35. try_files $uri $uri/ /index.html;
  36. }
  37. location @selkies_websocket {
  38. proxy_pass http://127.0.0.1:8081;
  39. proxy_http_version 1.1;
  40. proxy_set_header Upgrade $http_upgrade;
  41. proxy_set_header Connection $connection_upgrade;
  42. proxy_set_header Host $host;
  43. proxy_set_header Authorization $http_authorization;
  44. proxy_set_header X-Real-IP $remote_addr;
  45. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  46. proxy_set_header X-Forwarded-Proto $scheme;
  47. proxy_read_timeout 86400s;
  48. proxy_send_timeout 86400s;
  49. proxy_connect_timeout 30s;
  50. proxy_buffering off;
  51. }
  52. }
  53. }