nginx.conf 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. # Bookmarks
  48. rewrite ^/bookmarks/?$ /bookmarks.php break;
  49. # Who to follow
  50. rewrite ^/whotofollow/?$ /who_to_follow.php break;
  51. # Direct
  52. rewrite ^/direct/?$ /direct.php break;
  53. # Instance
  54. rewrite ^/instance/?$ /instance.php break;
  55. # Lists
  56. rewrite ^/lists/?$ /lists.php break;
  57. rewrite ^/lists/(\d+)/?$ /lists_view.php?id=$1 break;
  58. rewrite ^/lists/(\d+)/add/?$ /lists_add.php?id=$1 break;
  59. # Search
  60. rewrite ^/search/?$ /search_hash_tag.php break;
  61. rewrite ^/search/users/?$ /search_user.php break;
  62. # Settings
  63. rewrite ^/settings/?$ /settings_general.php break;
  64. rewrite ^/settings/profile/?$ /settings_profile.php break;
  65. rewrite ^/settings/appearance/?$ /settings_appearance.php break;
  66. rewrite ^/settings/filters/?$ /settings_filters.php break;
  67. rewrite ^/settings/media/?$ /settings_media.php break;
  68. rewrite ^/settings/followers/?$ /settings_accounts.php break;
  69. rewrite ^/settings/mutes/?$ /settings_accounts.php break;
  70. rewrite ^/settings/blocks/?$ /settings_accounts.php break;
  71. # User
  72. rewrite ^/@(.+)@(.+)\.([a-z]+)/?$ /user.php?user=@$1@$2\.$3 break;
  73. rewrite ^/@(.+)@(.+)\.([a-z]+)/status/(.+?)?$ /user.php?user=@$1@$2\.$3&status=$4 break;
  74. rewrite ^/@(.+)@(.+)\.([a-z]+)/media/?$ /user_only_media.php?user=@$1@$2\.$3 break;
  75. rewrite ^/@(.+)@(.+)\.([a-z]+)/with_replies/?$ /user_include_replies.php?user=@$1@$2\.$3 break;
  76. rewrite ^/@(.+)@(.+)\.([a-z]+)/followers/?$ /user_followers.php?user=@$1@$2\.$3 break;
  77. rewrite ^/@(.+)@(.+)\.([a-z]+)/following/?$ /user_following.php?user=@$1@$2\.$3 break;
  78. rewrite ^/@(.+)@(.+)\.([a-z]+)/favourites/?$ /user_favorite.php?user=@$1@$2\.$3 break;
  79. # Image
  80. rewrite ^/avatars/original/missing.png$ /assets/images/missing.png break;
  81. rewrite ^/headers/original/missing.png$ /assets/images/missing_header.png break;
  82. # 404
  83. rewrite ^/404/?$ /404.php break;
  84. location ~ [^/]\.php(/|$) {
  85. fastcgi_split_path_info ^(.+?\.php)(/.*)$;
  86. include fastcgi_params;
  87. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  88. if (!-f $document_root$fastcgi_script_name) {
  89. return 404;
  90. }
  91. fastcgi_param PATH_INFO $fastcgi_path_info;
  92. fastcgi_param HTTPS on;
  93. fastcgi_buffers 8 256k;
  94. fastcgi_buffer_size 128k;
  95. fastcgi_intercept_errors on;
  96. fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
  97. }
  98. }