wordpress-http3.sh 965 B

1234567891011121314151617181920212223242526272829
  1. #!/bin/bash
  2. user="$1"
  3. domain="$2"
  4. ip="$3"
  5. home="$4"
  6. # Build the path to the domain's configuration directory.
  7. domain_conf_path="${home}/${user}/conf/web/${domain}"
  8. # Path to the Nginx SSL configuration file for this domain.
  9. nginx_conf="${domain_conf_path}/nginx.ssl.conf"
  10. # Check if any file under /etc/nginx/conf.d/domains/ contains a line
  11. # with this IP followed by “quic reuseport;”. If not, proceed.
  12. if ! grep -qR "${ip}.*quic reuseport" /etc/nginx/conf.d/domains/; then
  13. # Modify the domain's nginx config: replace "quic" with "quic reuseport"
  14. # to enable the reuseport option for QUIC.
  15. sed -i.bak 's/quic/quic reuseport/' "$nginx_conf"
  16. # Test the nginx configuration to ensure it is valid.
  17. if nginx_check="$(nginx -t)"; then
  18. rm -f "${nginx_conf}.bak"
  19. systemctl reload nginx
  20. else
  21. echo "Error: nginx conf is not valid" >&2
  22. echo "$nginx_check" >&2
  23. echo "Restoring nginc.ssl.conf backup file"
  24. mv "${nginx_conf}.bak" "${nginx_conf}"
  25. fi
  26. fi