nginx.conf 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. server {
  2. listen 443 ssl http2;
  3. listen [::]:443 ssl http2;
  4. server_name pixelfed.example; # change this to your fqdn
  5. root /home/pixelfed/public; # path to repo/public
  6. ssl_certificate /etc/nginx/ssl/server.crt; # generate your own
  7. ssl_certificate_key /etc/nginx/ssl/server.key; # or use letsencrypt
  8. ssl_protocols TLSv1.2;
  9. ssl_ciphers EECDH+AESGCM:EECDH+CHACHA20:EECDH+AES;
  10. ssl_prefer_server_ciphers on;
  11. #add_header X-Frame-Options "SAMEORIGIN";
  12. add_header X-XSS-Protection "1; mode=block";
  13. add_header X-Content-Type-Options "nosniff";
  14. index index.php;
  15. charset utf-8;
  16. client_max_body_size 15M;
  17. location / {
  18. try_files $uri $uri/ /index.php?$query_string;
  19. }
  20. location = /favicon.ico { access_log off; log_not_found off; }
  21. location = /robots.txt { access_log off; log_not_found off; }
  22. error_page 404 /index.php;
  23. location ~ \.php$ {
  24. fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
  25. fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
  26. fastcgi_param QUERY_STRING $query_string;
  27. fastcgi_param REQUEST_METHOD $request_method;
  28. fastcgi_param CONTENT_TYPE $content_type;
  29. fastcgi_param CONTENT_LENGTH $content_length;
  30. fastcgi_param SCRIPT_NAME $fastcgi_script_name;
  31. fastcgi_param REQUEST_URI $request_uri;
  32. fastcgi_param DOCUMENT_URI $document_uri;
  33. fastcgi_param DOCUMENT_ROOT $document_root;
  34. fastcgi_param SERVER_PROTOCOL $server_protocol;
  35. fastcgi_param GATEWAY_INTERFACE CGI/1.1;
  36. fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
  37. fastcgi_param REMOTE_ADDR $remote_addr;
  38. fastcgi_param REMOTE_PORT $remote_port;
  39. fastcgi_param SERVER_ADDR $server_addr;
  40. fastcgi_param SERVER_PORT $server_port;
  41. fastcgi_param SERVER_NAME $server_name;
  42. fastcgi_param HTTPS $https if_not_empty;
  43. fastcgi_param REDIRECT_STATUS 200;
  44. fastcgi_param HTTP_PROXY "";
  45. }
  46. location ~ /\.(?!well-known).* {
  47. deny all;
  48. }
  49. }
  50. server { # Redirect http to https
  51. server_name pixelfed.example; # change this to your fqdn
  52. listen 80;
  53. listen [::]:80;
  54. return 301 https://$host$request_uri;
  55. }