nginx.conf 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. worker_processes 1;
  2. events {
  3. worker_connections 1024;
  4. }
  5. http {
  6. include mime.types;
  7. default_type application/octet-stream;
  8. sendfile on;
  9. keepalive_timeout 65;
  10. gzip on;
  11. gzip_min_length 1k;
  12. gzip_buffers 16 64K;
  13. gzip_http_version 1.1;
  14. gzip_comp_level 5;
  15. gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml;
  16. gzip_vary on;
  17. gzip_proxied expired no-cache no-store private auth;
  18. gzip_disable "MSIE [1-6]\.";
  19. # Http跳转Https
  20. # server {
  21. # listen 80;
  22. # server_name localhost;
  23. # location / {
  24. # rewrite ^(.*) https://$server_name$1 permanent;
  25. # }
  26. # }
  27. server {
  28. listen 80;
  29. # SSL 默认访问端口号为443
  30. listen 443 ssl;
  31. server_name localhost;
  32. charset utf-8;
  33. # 证书文件的路径
  34. ssl_certificate /usr/share/nginx/ssl/fastbee.crt;
  35. # 私钥文件的路径
  36. ssl_certificate_key /usr/share/nginx/ssl/fastbee.key;
  37. ssl_session_timeout 10m;
  38. # 请按照以下协议配置
  39. ssl_protocols TLSv1.2 TLSv1.3;
  40. # 请按照以下套件配置,配置加密套件,写法遵循openssl 标准
  41. ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
  42. ssl_prefer_server_ciphers on;
  43. # 前端
  44. location / {
  45. root /usr/share/nginx/html;
  46. try_files $uri $uri/ /index.html;
  47. index index.html index.htm;
  48. }
  49. # H5移动端
  50. location /h5 {
  51. alias /usr/share/nginx/h5/;
  52. try_files $uri $uri/ /index.html;
  53. index index.html index.htm;
  54. }
  55. # 后端接口
  56. location /prod-api/ {
  57. proxy_set_header Host $http_host;
  58. proxy_set_header X-Real-IP $remote_addr;
  59. proxy_set_header REMOTE-HOST $remote_addr;
  60. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  61. proxy_pass http://java:8080/;
  62. }
  63. # wss连接代理到ws
  64. location /mqtt {
  65. proxy_pass http://java:8083/mqtt;
  66. proxy_read_timeout 60s;
  67. proxy_set_header Host $host;
  68. proxy_set_header X-Real_IP $remote_addr;
  69. proxy_set_header X-Forwarded-for $remote_addr;
  70. proxy_http_version 1.1;
  71. proxy_set_header Upgrade $http_upgrade;
  72. proxy_set_header Connection 'Upgrade';
  73. }
  74. error_page 500 502 503 504 /50x.html;
  75. location = /50x.html {
  76. root html;
  77. }
  78. }
  79. }