nginx.conf 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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_split_path_info ^(.+\.php)(/.+)$;
  25. fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
  26. fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
  27. fastcgi_param QUERY_STRING $query_string;
  28. fastcgi_param REQUEST_METHOD $request_method;
  29. fastcgi_param CONTENT_TYPE $content_type;
  30. fastcgi_param CONTENT_LENGTH $content_length;
  31. fastcgi_param SCRIPT_NAME $fastcgi_script_name;
  32. fastcgi_param REQUEST_URI $request_uri;
  33. fastcgi_param DOCUMENT_URI $document_uri;
  34. fastcgi_param DOCUMENT_ROOT $document_root;
  35. fastcgi_param SERVER_PROTOCOL $server_protocol;
  36. fastcgi_param GATEWAY_INTERFACE CGI/1.1;
  37. fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
  38. fastcgi_param REMOTE_ADDR $remote_addr;
  39. fastcgi_param REMOTE_PORT $remote_port;
  40. fastcgi_param SERVER_ADDR $server_addr;
  41. fastcgi_param SERVER_PORT $server_port;
  42. fastcgi_param SERVER_NAME $server_name;
  43. fastcgi_param HTTPS $https if_not_empty;
  44. fastcgi_param REDIRECT_STATUS 200;
  45. fastcgi_param HTTP_PROXY "";
  46. }
  47. location ~ /\.(?!well-known).* {
  48. deny all;
  49. }
  50. }
  51. server { # Redirect http to https
  52. server_name pixelfed.example; # change this to your fqdn
  53. listen 80;
  54. listen [::]:80;
  55. return 301 https://$host$request_uri;
  56. }