nginx.conf.sample 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. # GNU social MUST be installed in the domain root
  20. server_name social.example.org;
  21. # SSL
  22. # FIXME: Change the paths to setup your SSL key/cert. See https://cipherli.st/ for more information
  23. ssl_certificate ssl/certs/social.example.org.crt;
  24. ssl_certificate_key ssl/private/social.example.org.key;
  25. # Logs
  26. # FIXME: Uncomment and change the paths to setup logging
  27. # access_log /path/to/access.log;
  28. # error_log /path/to/error.log;
  29. # Index
  30. index index.php;
  31. # PHP
  32. location ~ /index.php {
  33. include fastcgi_params;
  34. include snippets/fastcgi-php.conf;
  35. fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
  36. fastcgi_param SCRIPT_FILENAME $request_filename;
  37. # Further optional configuration
  38. # fastcgi_buffer_size 128K;
  39. # fastcgi_buffers 4 256K;
  40. # fastcgi_busy_buffers_size 256K;
  41. # fastcgi_read_timeout 600s;
  42. # fastcgi_send_timeout 300s;
  43. # fastcgi_connect_timeout 75s;
  44. # http2_push_preload on;
  45. }
  46. # Don't allow any PHP file other than index.php to be executed
  47. # This will ensure that nor config.php nor plugin files with eventual hardcoded security information are downloadable
  48. # And this is better than allowing php files to be executed in case of forgotten `if (!defined('GNUSOCIAL')) { exit(1); }`
  49. location ~ \.php$ {
  50. deny all;
  51. }
  52. # Location
  53. location / {
  54. try_files $uri $uri/ @index_handler;
  55. }
  56. # Fancy URLs
  57. error_page 404 @index_handler;
  58. location @index_handler {
  59. rewrite ^(.*)$ /index.php?p=$1 last;
  60. }
  61. # Restrict access that is unnecessary anyway
  62. location ~ /\.(ht|git) {
  63. deny all;
  64. }
  65. #
  66. # Hardening (optional)
  67. #
  68. # add_header Strict-Transport-Security "max-age=15768000; preload;";
  69. # add_header X-Content-Type-Options nosniff;
  70. # add_header Referrer-Policy strict-origin-when-cross-origin;
  71. # 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:;";
  72. # add_header X-Permitted-Cross-Domain-Policies none;
  73. # add_header X-Robots-Tag all; # Not really hardening, just here for strictness purposes
  74. #
  75. # client_max_body_size 15M;
  76. # client_body_buffer_size 128k;
  77. # gzip_vary on;
  78. #
  79. # location ~* \.(?:css|js|woff|svg|gif|png|webp|ttf|ico|jpe?g)$ {
  80. # gzip on;
  81. # gzip_comp_level 4;
  82. # add_header Cache-Control "public";
  83. # expires 30d;
  84. # access_log off;
  85. # log_not_found off;
  86. # }
  87. }