nginx.conf.sample 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. server {
  2. listen [::]:80;
  3. listen 80;
  4. # FIXME: Change domain name here (and also make sure you do the same in the next 'server' section)
  5. server_name social.example.org;
  6. # redirect all traffic to HTTPS
  7. rewrite ^ https://$host$request_uri? permanent;
  8. }
  9. server {
  10. # HTTPS is mandatory on GNU social unless you are using Tor network. Seriously.
  11. # Set it up with a cert (any cert) before you run the install.
  12. listen [::]:443 ssl http2;
  13. listen 443 ssl http2;
  14. # Root
  15. # FIXME: Change the path below to where you installed GNU social
  16. root /path/to/gnusocial/root;
  17. # Server name
  18. # FIXME: Change "social.example.org" to your site's domain name
  19. server_name social.example.org;
  20. # SSL
  21. # FIXME: Change the paths to setup your SSL key/cert. See https://cipherli.st/ for more information
  22. ssl_certificate ssl/certs/social.example.org.crt;
  23. ssl_certificate_key ssl/private/social.example.org.key;
  24. # Index
  25. index index.php;
  26. # PHP
  27. location ~ ^/(index|install)\.php$ {
  28. #location ^~ /index.php {
  29. include fastcgi_params;
  30. include snippets/fastcgi-php.conf;
  31. fastcgi_pass unix:/run/php/php-fpm.sock;
  32. fastcgi_param SCRIPT_FILENAME $request_filename;
  33. }
  34. # Don't allow any PHP file other than index.php to be executed
  35. # This will ensure that nor config.php nor plugin files with eventual hardcoded security information are downloadable
  36. # And this is better than allowing php files to be executed in case of forgotten `if (!defined('GNUSOCIAL')) { exit(1); }`
  37. location ~ \.php$ {
  38. deny all;
  39. }
  40. # Location
  41. location / {
  42. try_files $uri $uri/ @index_handler;
  43. }
  44. # Fancy URLs
  45. error_page 404 @index_handler;
  46. location @index_handler {
  47. rewrite ^(.*)$ /index.php?p=$1 last;
  48. }
  49. # Restrict access that is unnecessary anyway
  50. location ~ /\.(ht|git) {
  51. deny all;
  52. }
  53. #
  54. # Hardening (optional)
  55. #
  56. # add_header Strict-Transport-Security "max-age=15768000; preload;";
  57. # add_header X-Content-Type-Options nosniff;
  58. # add_header Referrer-Policy strict-origin-when-cross-origin;
  59. # 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:;";
  60. # add_header X-Permitted-Cross-Domain-Policies none;
  61. # add_header X-Robots-Tag all; # Not really hardening, just here for strictness purposes
  62. #
  63. # client_max_body_size 15M;
  64. # client_body_buffer_size 128k;
  65. # gzip_vary on;
  66. #
  67. # location ~* \.(?:css|js|woff|svg|gif|png|webp|ttf|ico|jpe?g)$ {
  68. # gzip on;
  69. # gzip_comp_level 4;
  70. # add_header Cache-Control "public";
  71. # expires 30d;
  72. # access_log off;
  73. # log_not_found off;
  74. # }
  75. }