nginx.conf 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. server {
  2. listen 80;
  3. listen [::]:80;
  4. server_name YOUR_DOMAIN;
  5. return 301 https://$server_name$request_uri;
  6. }
  7. server {
  8. listen 443 ssl http2;
  9. listen [::]:443 ssl http2;
  10. server_name YOUR_DOMAIN;
  11. ssl_protocols TLSv1.2;
  12. ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256';
  13. ssl_prefer_server_ciphers on;
  14. ssl_session_cache shared:SSL:10m;
  15. ssl_stapling on;
  16. ssl_stapling_verify on;
  17. add_header Strict-Transport-Security "max-age=31536000";
  18. add_header X-XSS-Protection "1; mode=block";
  19. ssl_certificate /etc/CHANGE_THIS/fullchain.pem;
  20. ssl_certificate_key /etc/CHANGE_THIS/privkey.pem;
  21. ssl_dhparam /etc/CHANGE_THIS/dhparam.pem;
  22. keepalive_timeout 70;
  23. sendfile on;
  24. client_max_body_size 20m;
  25. root /var/www/example.com;
  26. location ~* (?:DESIGN|(?:gpl|README|LICENSE)[^.]*|LEGALNOTICE)(?:\.txt)*$ {
  27. return 302 /;
  28. }
  29. location ~* \.(?:bat|git|ini|sh|svn[^.]*|txt|tpl|xml)$ {
  30. return 404;
  31. }
  32. # Main
  33. rewrite ^/home/?$ / permanent;
  34. rewrite ^/intent/toot/?$ /share.php break;
  35. rewrite ^/login/?$ /login/login.php break;
  36. rewrite ^/auth/?$ /login/auth.php break;
  37. rewrite ^/logout/?$ /login/logout.php break;
  38. rewrite ^/terms/?$ /login/terms.php break;
  39. rewrite ^/privacy/?$ /login/privacy.php break;
  40. rewrite ^/imprint/?$ /login/imprint.php break;
  41. # LTL
  42. rewrite ^/local/?$ /local.php break;
  43. # FTL
  44. rewrite ^/federated/?$ /federated.php break;
  45. # Notice
  46. rewrite ^/notifications/?$ /notifications.php break;
  47. # Who to follow
  48. rewrite ^/whotofollow/?$ /who_to_follow.php break;
  49. # Direct
  50. rewrite ^/direct/?$ /direct.php break;
  51. # Instance
  52. rewrite ^/instance/?$ /instance.php break;
  53. # Lists
  54. rewrite ^/lists/?$ /lists.php break;
  55. rewrite ^/lists/(\d+)/?$ /lists_view.php?id=$1 break;
  56. rewrite ^/lists/(\d+)/add/?$ /lists_add.php?id=$1 break;
  57. # Search
  58. rewrite ^/search/?$ /search_hash_tag.php break;
  59. rewrite ^/search/users/?$ /search_user.php break;
  60. # Settings
  61. rewrite ^/settings/?$ /settings_general.php break;
  62. rewrite ^/settings/profile/?$ /settings_profile.php break;
  63. rewrite ^/settings/appearance/?$ /settings_appearance.php break;
  64. rewrite ^/settings/filters/?$ /settings_filters.php break;
  65. rewrite ^/settings/media/?$ /settings_media.php break;
  66. rewrite ^/settings/followers/?$ /settings_accounts.php break;
  67. rewrite ^/settings/mutes/?$ /settings_accounts.php break;
  68. rewrite ^/settings/blocks/?$ /settings_accounts.php break;
  69. # User
  70. rewrite ^/@(.+)@(.+)\.([a-z]+)/?$ /user.php?user=@$1@$2\.$3 break;
  71. rewrite ^/@(.+)@(.+)\.([a-z]+)/status/(.+?)?$ /user.php?user=@$1@$2\.$3&status=$4 break;
  72. rewrite ^/@(.+)@(.+)\.([a-z]+)/media/?$ /user_only_media.php?user=@$1@$2\.$3 break;
  73. rewrite ^/@(.+)@(.+)\.([a-z]+)/with_replies/?$ /user_include_replies.php?user=@$1@$2\.$3 break;
  74. rewrite ^/@(.+)@(.+)\.([a-z]+)/followers/?$ /user_followers.php?user=@$1@$2\.$3 break;
  75. rewrite ^/@(.+)@(.+)\.([a-z]+)/following/?$ /user_following.php?user=@$1@$2\.$3 break;
  76. rewrite ^/@(.+)@(.+)\.([a-z]+)/favourites/?$ /user_favorite.php?user=@$1@$2\.$3 break;
  77. # Image
  78. rewrite ^/avatars/original/missing.png$ /assets/images/missing.png break;
  79. rewrite ^/headers/original/missing.png$ /assets/images/missing_header.png break;
  80. # 404
  81. rewrite ^/404/?$ /404.php break;
  82. location ~ [^/]\.php(/|$) {
  83. fastcgi_split_path_info ^(.+?\.php)(/.*)$;
  84. include fastcgi_params;
  85. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  86. if (!-f $document_root$fastcgi_script_name) {
  87. return 404;
  88. }
  89. fastcgi_param PATH_INFO $fastcgi_path_info;
  90. fastcgi_param HTTPS on;
  91. fastcgi_buffers 8 256k;
  92. fastcgi_buffer_size 128k;
  93. fastcgi_intercept_errors on;
  94. fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
  95. }
  96. }