nginx.conf.sample 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 (GNU social's root + /public)
  16. root /var/www/gnusocial/public;
  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. # X-Accel/X-Sendfile. Still needs to be enabled in the config
  27. location /file {
  28. internal;
  29. # FIXME: Change "/path/to/gnusocial/root/" to the folder where
  30. # attachments are stored (normally the same as the site root)
  31. root /path/to/gnusocial/root/;
  32. }
  33. # PHP
  34. location ~ ^/(index|install)\.php(/.*)?$ {
  35. #location ^~ /index.php {
  36. include fastcgi_params;
  37. include snippets/fastcgi-php.conf;
  38. fastcgi_pass unix:/run/php/php-fpm.sock;
  39. fastcgi_param SCRIPT_FILENAME $request_filename;
  40. }
  41. # Don't allow any PHP file other than index.php to be executed
  42. # This will ensure that nor config.php nor plugin files with eventual hardcoded security information are downloadable
  43. # And this is better than allowing php files to be executed in case of forgotten `if (!defined('GNUSOCIAL')) { exit(1); }`
  44. location ~ \.php$ {
  45. deny all;
  46. }
  47. # Location
  48. location / {
  49. try_files $uri $uri/ @index_handler;
  50. }
  51. # Fancy URLs
  52. error_page 404 @index_handler;
  53. location @index_handler {
  54. rewrite ^(.*)$ /index.php?p=$1 last;
  55. }
  56. # Restrict access that is unnecessary anyway
  57. location ~ /\.(ht|git) {
  58. deny all;
  59. }
  60. #
  61. # Hardening (optional)
  62. #
  63. # add_header Strict-Transport-Security "max-age=15768000; preload;";
  64. # add_header X-Content-Type-Options nosniff;
  65. # add_header Referrer-Policy strict-origin-when-cross-origin;
  66. # 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:;";
  67. # add_header X-Permitted-Cross-Domain-Policies none;
  68. # add_header X-Robots-Tag all; # Not really hardening, just here for strictness purposes
  69. #
  70. # client_max_body_size 15M;
  71. # client_body_buffer_size 128k;
  72. # gzip_vary on;
  73. #
  74. # location ~* \.(?:css|js|woff|svg|gif|png|webp|ttf|ico|jpe?g)$ {
  75. # gzip on;
  76. # gzip_comp_level 4;
  77. # add_header Cache-Control "public";
  78. # expires 30d;
  79. # access_log off;
  80. # log_not_found off;
  81. # }
  82. }