nginx.conf.sample 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. fastcgi_split_path_info ^(.+?\.php)(/.*)$;
  38. set $path_info $fastcgi_path_info;
  39. try_files $fastcgi_script_name =404;
  40. fastcgi_pass unix:/run/php/php7.X-fpm.sock;
  41. fastcgi_index index.php;
  42. fastcgi_param PATH_INFO $path_info;
  43. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  44. }
  45. # Don't allow any PHP file other than index.php to be executed
  46. # This will ensure that nor config.php nor plugin files with eventual hardcoded security information are downloadable
  47. # And this is better than allowing php files to be executed in case of forgotten `if (!defined('GNUSOCIAL')) { exit(1); }`
  48. location ~ \.php$ {
  49. deny all;
  50. }
  51. # Location
  52. location / {
  53. try_files $uri $uri/ @index_handler;
  54. }
  55. # Fancy URLs
  56. error_page 404 @index_handler;
  57. location @index_handler {
  58. rewrite ^(.*)$ /index.php?p=$1 last;
  59. }
  60. # Restrict access that is unnecessary anyway
  61. location ~ /\.(ht|git) {
  62. deny all;
  63. }
  64. #
  65. # Hardening (optional)
  66. #
  67. # add_header Strict-Transport-Security "max-age=15768000; preload;";
  68. # add_header X-Content-Type-Options nosniff;
  69. # add_header Referrer-Policy strict-origin-when-cross-origin;
  70. # 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:;";
  71. # add_header X-Permitted-Cross-Domain-Policies none;
  72. # add_header X-Robots-Tag all; # Not really hardening, just here for strictness purposes
  73. #
  74. # client_max_body_size 15M;
  75. # client_body_buffer_size 128k;
  76. # gzip_vary on;
  77. #
  78. # location ~* \.(?:css|js|woff|svg|gif|png|webp|ttf|ico|jpe?g)$ {
  79. # gzip on;
  80. # gzip_comp_level 4;
  81. # add_header Cache-Control "public";
  82. # expires 30d;
  83. # access_log off;
  84. # log_not_found off;
  85. # }
  86. }