外部访问支持http和https,但是nginx内部统一把请求转换成https转发出去

  1. server {
  2. listen 80;
  3. server_name sunfj.cn;
  4. ## root www/mimvp_proxy;
  5. rewrite ^(.*)host$1 permanent;##强制httphttps请求
  6. }
  7. server {
  8. listen 443 ssl http2;
  9. server_name xxx.cn;
  10. ## root www/mimvp_proxy;
  11. ssl on;
  12. ssl_certificate /etc/ssl/certs/xxx.crt;
  13. ssl_certificate_key /etc/ssl/certs/xxx.key;
  14. ssl_session_cache shared:SSL:1m;
  15. ssl_session_timeout 10m;
  16. ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  17. ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
  18. ssl_prefer_server_ciphers on;
  19. location / {
  20.     proxy_pass /*proxy address*/;
  21. }
  22. location ~ .do$ {
  23.     proxy_pass /*proxy address*/;
  24. }
  25. location ~* ^/(images|img|javascript|js|css|blog|flash|media|static)/ {
  26. proxy_pass /*proxy address*/;
  27. }
  28. location ~* ^/favicon\.ico {
  29. proxy_pass /*proxy address*/;
  30. }
  31. location ~* ^/img/logo\.png {
  32. proxy_pass /*proxy address*/;
  33. }
  34. location ~ /\.ht {
  35. deny all;
  36. }
  37. }
  • 转发请求对应的header参数:underscores_in_headers on;
  • 超时时间配置(全局):
  1. fastcgi_connect_timeout 300;
  2. fastcgi_send_timeout 300;
  3. fastcgi_read_timeout 300;
  4. fastcgi_buffer_size 64k;
  5. fastcgi_buffers 4 64k;
  6. fastcgi_busy_buffers_size 128k;
  7. fastcgi_temp_file_write_size 128k;
  • 启动Nginx命令:
  1. docker run --name some-nginx -v /some/content:/usr/share/nginx/html:ro -d nginx
  • 反向代理启动命令:
  1. docker run --name nginx -p 80:80 -p 443:443 -v /home/data/nginx/nginx.conf:/etc/nginx/nginx.conf -v /home/data/nginx/conf.d:/etc/nginx/conf.d -v /etc/ssl/certs:/etc/ssl/certs -d nginx

版权声明:本文为sunfujian原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/sunfujian/p/12507536.html