Newer
Older
WordPress-Load-Balance-Layer-7 / block.sh
  1. #!/bin/bash
  2.  
  3. echo "server {
  4. root /var/www/html/wp;
  5. index index.php index.html index.htm;
  6. server_name your-site-name.tld;
  7. server_tokens off;
  8. access_log /var/log/nginx/frontend_access.log;
  9. error_log /var/log/nginx/frontend_error.log;
  10. gzip on;
  11. gzip_vary on;
  12. gzip_min_length 10240;
  13. gzip_proxied expired no-cache no-store private auth;
  14. gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml application/javascript text/x-javascript;
  15. gzip_disable "MSIE [1-6]\.";
  16.  
  17.  
  18. location / {
  19. try_files $uri $uri/ /index.php?$args;
  20. proxy_headers_hash_max_size 512;
  21. proxy_headers_hash_bucket_size 64;
  22. proxy_set_header Host $host;
  23. proxy_set_header X-Forwarded-Proto $scheme;
  24. proxy_set_header X-Real-IP $remote_addr;
  25. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  26. add_header Front-End-Https on;
  27. }
  28.  
  29. location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
  30. expires 365d;
  31. }
  32.  
  33. location ~* \.(pdf)$ {
  34. expires 30d;
  35. }
  36. location ~ \.php$ {
  37. fastcgi_pass 127.0.0.1:9000;
  38. fastcgi_index index.php;
  39. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  40. include fastcgi_params;
  41. }
  42. }" > /etc/nginx/conf.d/blocks.conf
  43.  
  44. nginx -t;
  45. nginx -s reload;
  46. systemctl status nginx;