Guest User

NGinx

a guest
May 20th, 2020
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.62 KB | None | 0 0
  1. server {
  2. if ($host = www.website.com) {
  3. return 301 https://$host$request_uri;
  4. } # managed by Certbot
  5.  
  6.  
  7. if ($host = website.com) {
  8. return 301 https://$host$request_uri;
  9. } # managed by Certbot
  10.  
  11. listen 80;
  12. server_name website.com www.website.com;
  13. access_log /var/log/nginx/website.com.access.log;
  14. error_log /var/log/nginx/website.com.error.log;
  15. root /srv/website.com;
  16. client_max_body_size 100m;
  17. location / {
  18. index index.php;
  19. }
  20. location /.well-known/acme-challenge {
  21. root /srv/website.com/letsencrypt;
  22. }
  23. location ~ \.php$ {
  24. fastcgi_split_path_info ^(.+?\.php)(/.*)$;
  25. if (!-f $document_root$fastcgi_script_name) {
  26. return 404;
  27. }
  28. # Mitigate https://httpoxy.org/ vulnerabilities
  29. fastcgi_param HTTP_PROXY "";
  30. fastcgi_pass 127.0.0.1:9000;
  31. fastcgi_index index.php;
  32. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  33. include /etc/nginx/fastcgi_params;
  34. }
  35. }
  36. server {
  37. listen 443;
  38. ssl on;
  39. ssl_certificate /etc/letsencrypt/live/website.com/fullchain.pem; # managed by Certbot
  40. ssl_certificate_key /etc/letsencrypt/live/website.com/privkey.pem; # managed by Certbot
  41. server_name website.com www.website.com;
  42. access_log /var/log/nginx/ssl-website.com.access.log;
  43. error_log /var/log/nginx/ssl-website.com.error.log;
  44. root /srv/website.com;
  45. client_max_body_size 100m;
  46.  
  47. #website links
  48. location / {
  49. try_files $uri $uri/ /index.php$is_args$args;
  50. index index.php;
  51. add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS";
  52. add_header Access-Control-Allow-Origin $http_origin;
  53. if ($request_method = OPTIONS) {
  54. add_header Content-Length 0;
  55. add_header Content-Type text/plain;
  56. add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS";
  57. add_header Access-Control-Allow-Origin $http_origin;
  58. add_header Access-Control-Allow-Headers "Authorization, Content-Type, Access-Control-Allow-Origin";
  59. add_header Access-Control-Allow-Credentials true;
  60. return 200;
  61. }
  62. }
  63. location /server-status {
  64. stub_status on;
  65. access_log false;
  66. allow 127.0.0.1;
  67. deny all;
  68. }
  69. location ~ [^/]\.php(/|$) {
  70. fastcgi_split_path_info ^(.+?\.php)(/.*)$;
  71. if (!-f $document_root$fastcgi_script_name) {
  72. return 404;
  73. }
  74.  
  75. # Mitigate https://httpoxy.org/ vulnerabilities
  76. fastcgi_param HTTP_PROXY "";
  77. fastcgi_pass 127.0.0.1:9000;
  78. fastcgi_index index.php;
  79. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  80. include /etc/nginx/fastcgi_params;
  81. }
  82. }
Add Comment
Please, Sign In to add comment