nginx.conf 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. server {
  2. listen 80;
  3. server_name localhost;
  4. # Increase client body size limit for file uploads
  5. client_max_body_size 500M;
  6. # Serve Static Files
  7. location / {
  8. root /usr/share/nginx/html;
  9. index index.html index.htm;
  10. try_files $uri $uri/ /index.html;
  11. }
  12. # Proxy API requests to Backend
  13. location /api/ {
  14. proxy_pass http://backend:8000/api/;
  15. proxy_set_header Host $host;
  16. proxy_set_header X-Real-IP $remote_addr;
  17. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  18. # 大文件上传:读/写/连接超时 10 分钟
  19. proxy_connect_timeout 600s;
  20. proxy_send_timeout 600s;
  21. proxy_read_timeout 600s;
  22. # WebSocket Support
  23. proxy_http_version 1.1;
  24. proxy_set_header Upgrade $http_upgrade;
  25. proxy_set_header Connection "upgrade";
  26. }
  27. # Proxy OIDC (Hydra public) with /hydra prefix
  28. location /hydra/ {
  29. # Strip /hydra prefix before forwarding to Hydra
  30. rewrite ^/hydra/(.*)$ /$1 break;
  31. proxy_pass http://hydra:4444;
  32. proxy_http_version 1.1;
  33. proxy_set_header Host $host;
  34. proxy_set_header X-Real-IP $remote_addr;
  35. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  36. proxy_set_header X-Forwarded-Proto $scheme;
  37. }
  38. }
  39. server {
  40. listen 443 ssl;
  41. server_name localhost;
  42. ssl_certificate /etc/nginx/certs/server.crt;
  43. ssl_certificate_key /etc/nginx/certs/server.key;
  44. # SSL Settings
  45. ssl_session_timeout 1d;
  46. ssl_session_cache shared:SSL:50m;
  47. ssl_session_tickets off;
  48. ssl_protocols TLSv1.2 TLSv1.3;
  49. ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
  50. ssl_prefer_server_ciphers off;
  51. # Increase client body size limit for file uploads
  52. client_max_body_size 500M;
  53. # Serve Static Files
  54. location / {
  55. root /usr/share/nginx/html;
  56. index index.html index.htm;
  57. try_files $uri $uri/ /index.html;
  58. }
  59. # Proxy API requests to Backend
  60. location /api/ {
  61. proxy_pass http://backend:8000/api/;
  62. proxy_set_header Host $host;
  63. proxy_set_header X-Real-IP $remote_addr;
  64. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  65. # 大文件上传:读/写/连接超时 10 分钟
  66. proxy_connect_timeout 600s;
  67. proxy_send_timeout 600s;
  68. proxy_read_timeout 600s;
  69. # WebSocket Support
  70. proxy_http_version 1.1;
  71. proxy_set_header Upgrade $http_upgrade;
  72. proxy_set_header Connection "upgrade";
  73. }
  74. # Proxy OIDC (Hydra public) with /hydra prefix over HTTPS
  75. location /hydra/ {
  76. # Strip /hydra prefix before forwarding to Hydra
  77. rewrite ^/hydra/(.*)$ /$1 break;
  78. proxy_pass http://hydra:4444;
  79. proxy_http_version 1.1;
  80. proxy_set_header Host $host;
  81. proxy_set_header X-Real-IP $remote_addr;
  82. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  83. proxy_set_header X-Forwarded-Proto $scheme;
  84. }
  85. }