Advertisement
zashkurka

nginx maintenance page

Jan 10th, 2024 (edited)
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. #Server block to accept server ip address
  2. #Server block to accept www
  3. #Server block to redirect http to https
  4. # Main Server block to virtual host
  5. server {
  6. listen 443 ssl;
  7. listen [::]:443 ssl;
  8. server_name my_site;
  9. ssl_certificate /etc/letsencrypt/live/my_site/fullchain.pem;
  10. ssl_certificate_key /etc/letsencrypt/live/my_site/privkey.pem;
  11. ssl_trusted_certificate /etc/letsencrypt/live/my_site/chain.pem;
  12.  
  13. root /srv/my-site/public;
  14. index index.html;
  15. error_page 502 /502.html;
  16. location / {
  17. if ($remote_addr != "my.ip.goes.here") {
  18. return 503;
  19. }
  20. error_page 503 @maintenance;
  21. location @maintenance {
  22. rewrite ^(.*)$ /error503.html break;
  23. }
  24. try_files $uri @proxy;
  25. }
  26. location @proxy {
  27. proxy_redirect off;
  28. proxy_http_version 1.1;
  29. proxy_set_header Upgrade $http_upgrade;
  30. proxy_set_header Connection $connection_upgrade;
  31. proxy_set_header Proxy '';
  32. proxy_set_header Host $http_host;
  33. proxy_set_header X-Forwarded-Proto $scheme;
  34. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  35. proxy_set_header X-Real-IP $remote_addr;
  36.  
  37. set $backend http://127.0.0.1:8000;
  38. proxy_pass $backend;
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement