nginx.conf 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. # server {
  2. # server_name social.localhost;
  3. # # redirect all traffic to HTTPS
  4. # rewrite ^ https://$host$request_uri? permanent;
  5. # }
  6. server {
  7. listen [::]:80;
  8. listen 80;
  9. # Root
  10. root /var/www/gnusocial/public;
  11. # Server name
  12. server_name social.localhost;
  13. # Index
  14. index index.php;
  15. # X-Accel/X-Sendfile. Still needs to be enabled in the config
  16. location /file {
  17. internal;
  18. # FIXME: Change "/path/to/gnusocial/root/" to the folder where
  19. # attachments are stored (normally the same as the site root)
  20. root /var/www/gnusocial;
  21. }
  22. # PHP
  23. location ~ ^/(index|install)\.php(/.*)?$ {
  24. include fastcgi_params;
  25. fastcgi_split_path_info ^(.+?\.php)(/.*)$;
  26. set $path_info $fastcgi_path_info;
  27. try_files $fastcgi_script_name =404;
  28. fastcgi_pass php:9000;
  29. fastcgi_index index.php;
  30. fastcgi_param PATH_INFO $path_info;
  31. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  32. }
  33. # Don't allow any PHP file other than index.php to be executed
  34. # This will ensure that nor config.php nor plugin files with eventual hardcoded security information are downloadable
  35. # And this is better than allowing php files to be executed in case of forgotten `if (!defined('GNUSOCIAL')) { exit(1); }`
  36. location ~ \.php$ {
  37. deny all;
  38. }
  39. # Location
  40. location / {
  41. try_files $uri $uri/ @index_handler;
  42. }
  43. # Fancy URLs
  44. error_page 404 @index_handler;
  45. location @index_handler {
  46. rewrite ^(.*)$ /index.php?p=$1 last;
  47. }
  48. # Restrict access that is unnecessary anyway
  49. location ~ /\.(ht|git) {
  50. deny all;
  51. }
  52. #
  53. # Hardening (optional)
  54. #
  55. # add_header Strict-Transport-Security "max-age=15768000; preload;";
  56. # add_header X-Content-Type-Options nosniff;
  57. # add_header Referrer-Policy strict-origin-when-cross-origin;
  58. # add_header Content-Security-Policy "default-src 'self' 'unsafe-inline'; frame-ancestors 'self'; form-action 'self'; style-src 'self' 'unsafe-inline'; img-src * blob: data:;";
  59. # add_header X-Permitted-Cross-Domain-Policies none;
  60. # add_header X-Robots-Tag all; # Not really hardening, just here for strictness purposes
  61. #
  62. # client_max_body_size 15M;
  63. # client_body_buffer_size 128k;
  64. # gzip_vary on;
  65. #
  66. # location ~* \.(?:css|js|woff|svg|gif|png|webp|ttf|ico|jpe?g)$ {
  67. # gzip on;
  68. # gzip_comp_level 4;
  69. # add_header Cache-Control "public";
  70. # expires 30d;
  71. # access_log off;
  72. # log_not_found off;
  73. # }
  74. }