Source code for my website.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

62 lines
1.3 KiB

  1. upstream node {
  2. server localhost:3000; # Host and Port of the Node.js application
  3. }
  4. server {
  5. listen 443 ssl http2;
  6. listen [::]:443 ssl http2;
  7. server_name example.com; # Change this with your own domain
  8. gzip on;
  9. ssl_certificate /path/to/cert.pem;
  10. ssl_certificate_key /path/to/private/key.pem;
  11. ssl_stapling on;
  12. ssl_stapling_verify on;
  13. ssl_trusted_certificate /path/to/fullchain.pem;
  14. ssl_session_timeout 5m;
  15. root /var/www/express-starter;
  16. location /static/ {
  17. }
  18. location / {
  19. proxy_pass http://node;
  20. proxy_set_header X-Real-IP $remote_addr;
  21. proxy_set_header Host $host;
  22. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  23. proxy_http_version 1.1;
  24. proxy_set_header Upgrade $http_upgrade;
  25. proxy_set_header Connection "upgrade";
  26. proxy_redirect off;
  27. }
  28. }
  29. server {
  30. if ($host = www.example.com) {
  31. rewrite ^/(.*) https://example.com/$1 permanent;
  32. }
  33. listen 443;
  34. listen [::]:443;
  35. server_name www.example.com;
  36. return 404;
  37. }
  38. server {
  39. if ($host = example.com) {
  40. return 301 https://$host$request_uri;
  41. }
  42. if ($host = www.example.com) {
  43. rewrite ^/(.*) https://example.com/$1 permanent;
  44. }
  45. listen 80;
  46. listen [::]:80;
  47. server_name www.example.com example.com;
  48. return 404;
  49. }