chat.sr.ht.conf 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. server {
  2. include sourcehut.conf;
  3. include port80.conf;
  4. server_name chat.localtest.me;
  5. client_max_body_size 100M;
  6. location / {
  7. # TODO: find a nicer way to do this
  8. if ($http_cookie !~* "sr.ht.unified-login.v1") {
  9. return 302 https://meta.sr.ht/login?return_to=$scheme://$host$request_uri;
  10. }
  11. root /usr/share/webapps/gamja;
  12. include headers.conf;
  13. # We have to use a weird connect-src because of a Safari bug
  14. # https://bugs.webkit.org/show_bug.cgi?id=201591
  15. add_header Content-Security-Policy "default-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline'; connect-src wss://chat.sr.ht https://chat.sr.ht" always;
  16. # TODO: setup caching
  17. }
  18. # Manifests aren't requested with cookies by default,
  19. # so it needs to be served in a location directive
  20. # that doesn't perform the auth redirect.
  21. location = /manifest.webmanifest {
  22. root /usr/share/webapps/gamja;
  23. }
  24. location /socket {
  25. proxy_pass http://srhts:8080;
  26. proxy_read_timeout 600s;
  27. proxy_http_version 1.1;
  28. proxy_set_header Upgrade $http_upgrade;
  29. proxy_set_header Connection "Upgrade";
  30. include web.conf;
  31. }
  32. location /config.json {
  33. proxy_pass http://srhts:8080;
  34. include web.conf;
  35. }
  36. location /metrics {
  37. proxy_pass http://srhts:6060;
  38. }
  39. }