Advertisement
Guest User

nginx virtualhost

a guest
Feb 22nd, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. fastcgi_cache_path /home/userchanged/cache levels=1:2 keys_zone=subdomain.domain.tld:100m inactive=60m;
  2.  
  3. server {
  4. listen 80;
  5. listen [::]:80;
  6. server_name subdomain.domain.tld;
  7. return 301 https://$server_name$request_uri;
  8. }
  9.  
  10.  
  11. server {
  12. listen 443 ssl http2;
  13. listen [::]:443 ssl http2;
  14. include snippets/ssl-subdomain.domain.tld.conf;
  15. include snippets/ssl-params.conf;
  16.  
  17. server_name subdomain.domain.tld;
  18.  
  19. access_log /home/userchanged/subdomain.domain.tld/logs/access.log;
  20. error_log /home/userchanged/subdomain.domain.tld/logs/error.log;
  21.  
  22. root /home/userchanged/subdomain.domain.tld/public/;
  23. index index.php;
  24.  
  25. set $skip_cache 0;
  26.  
  27. # POST requests and urls with a query string should always go to PHP
  28. if ($request_method = POST) {
  29. set $skip_cache 1;
  30. }
  31. if ($query_string != "") {
  32. set $skip_cache 1;
  33. }
  34.  
  35. # Don’t cache uris containing the following segments
  36. if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml") {
  37. set $skip_cache 1;
  38. }
  39.  
  40. # Don’t use the cache for logged in users or recent commenters
  41. if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
  42. set $skip_cache 1;
  43. }
  44.  
  45. location / {
  46. try_files $uri $uri/ /index.php?$args;
  47. }
  48.  
  49. location ~ \.php$ {
  50. try_files $uri =404;
  51. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  52. fastcgi_pass unix:/run/php/php7.1-fpm.sock;
  53. fastcgi_index index.php;
  54. include fastcgi_params;
  55. fastcgi_cache_bypass $skip_cache;
  56. fastcgi_no_cache $skip_cache;
  57. fastcgi_cache subdomain.domain.tld;
  58. fastcgi_cache_valid 60m;
  59. }
  60.  
  61. location ~ /.well-known {
  62. allow all;
  63. }
  64.  
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement