wildcard.sh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/bin/bash
  2. if [ ! -e /root/domain ]; then
  3. domin=$(cat /etc/v2ray/domain)
  4. else
  5. domin=$(cat /root/domain)
  6. fi
  7. cat > /etc/nginx/sites-enabled/wildcard_subdomain << END
  8. server {
  9. server_name *.${domin};
  10. access_log /var/log/nginx/vps-access.log;
  11. error_log /var/log/nginx/vps-error.log error;
  12. root /home/vps/public_html;
  13. location / {
  14. index index.html index.htm index.php;
  15. try_files $uri $uri/ /index.php?$args;
  16. }
  17. location ~\.php$ {
  18. include /etc/nginx/fastcgi_params;
  19. fastcgi_pass 127.0.0.1:9000;
  20. fastcgi_index index.php;
  21. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  22. }
  23. location ~ /\.ht {
  24. deny all;
  25. }
  26. location ~* /(?:uploads|files)/.*\.php$ {
  27. deny all;
  28. }
  29. location ~* \.(jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
  30. expires 356d;
  31. add_header Cache-Control "public, no-transform";
  32. }
  33. location ~* \.(css|js)$ {
  34. expires 2d;
  35. add_header Cache-Control "public, no-transform";
  36. }
  37. listen: 81;
  38. }
  39. END
  40. #listen 443 ssl;
  41. # ssl_certificate /etc/v2ray/v2ray.crt;
  42. # ssl_certificate_key /etc/v2ray/v2ray.key;
  43. systemctl daemon-reload
  44. systemctl restart nginx