当前位置: 首页 > news >正文

在Docker 上使用 Nginx 配置https及wss

预先创建挂载文件

/mydata/nginx/conf/nginx.conf 
/mydata/nginx/cert
/mydata/nginx/conf.d
/mydata/nginx/html
/mydata/nginx/logs

运行并且挂载容器

docker run -p 80:80 -p 443:443  --name nginx01 --restart=always \
-v /mydata/nginx/conf/nginx.conf:/etc/nginx/nginx.conf \
-v /mydata/nginx/cert:/etc/nginx/cert \
-v /mydata/nginx/conf.d:/etc/nginx/conf.d \
-v /mydata/nginx/html:/usr/share/nginx/html \
-v /mydata/nginx/logs:/var/log/nginx \
-d -it nginx

nginx.conf文件

user  nginx;
worker_processes  auto;error_log  /var/log/nginx/error.log notice;
pid        /var/run/nginx.pid;events {worker_connections  1024;
}http {include       /etc/nginx/mime.types;default_type  application/octet-stream;log_format  main  '$remote_addr - $remote_user [$time_local] "$request" ''$status $body_bytes_sent "$http_referer" ''"$http_user_agent" "$http_x_forwarded_for"';access_log  /var/log/nginx/access.log  main;sendfile        on;#tcp_nopush     on;keepalive_timeout  65;#gzip  on;include /etc/nginx/conf.d/*.conf;
}

default.conf文件

server{listen 80;listen  [::]:80;charset 'utf-8';server_name  chat.frankzhang.space;rewrite ^(.*) https://$server_name$1 permanent;error_page  404 /404.html; location = /404.html{root  /usr/share/nginx/html;}
}server{listen 443 ssl;server_name 域名;ssl_certificate  ***.pem;ssl_certificate_key ***.key;ssl_session_cache    shared:SSL:1m;ssl_session_timeout  5m;ssl_protocols SSLv3 SSLv2 TLSv1 TLSv1.1 TLSv1.2; #按照这个协议配置ssl_ciphers  HIGH:!aNULL:!MD5;ssl_prefer_server_ciphers  on;location / {#rewrite ^/(.*)$ /$1 break;proxy_pass http://服务器ip地址:端口号;        #通过配置端口指向部署websocker的项目proxy_http_version 1.1;    proxy_set_header Upgrade $http_upgrade;    proxy_set_header Connection "Upgrade";    proxy_set_header X-real-ip $remote_addr;proxy_set_header X-Forwarded-For $remote_addr;proxy_read_timeout 600s;			#设置连接自动断开时间}error_page  404 /404.html;             location = /404.html {root  /usr/share/nginx/html;}
}
http://www.lryc.cn/news/132046.html

相关文章:

  • git回退操作
  • C++系列-类和对象-静态成员
  • SAP MM学习笔记26- SAP中 振替转记(转移过账)和 在库转送(库存转储)2- 品目Code振替转记 和 在库转送
  • 【Python机器学习】实验13 基于神经网络的回归-分类实验
  • 【数据结构】二叉树的链式结构的实现 -- 详解
  • 【C语言】什么是结构体内存对齐?结构体的大小怎么计算?
  • 【Redis】Redis中的布隆过滤器
  • 接口测试 —— Jmeter 参数加密实现
  • Linux c语言字节序
  • 批量将excel中第5列中内容将人名和电话号码进行分列
  • WPF DataGrid columns表头根据数据集动态动态生成Demo
  • 1339. 分裂二叉树的最大乘积
  • 【C++】Stack和Queue
  • Maven之tomcat7-maven-plugin 版本低的问题
  • 在项目中如何解除idea和Git的绑定
  • AGI 在网易云信的技术提效和业务创新
  • 线性代数的学习和整理9(草稿-----未完成)
  • React的useReducer与Reudx对比
  • 深度学习环境搭建 cuda、模型量化bitsandbytes安装教程 windows、linux
  • pythond assert 0 <= colx < X12_MAX_COLS AssertionError
  • js简介以及在html中的2种使用方式(hello world)
  • vsCode使用cuda
  • ubuntu无法使用apt命令时怎么安装库
  • 防火墙firewall
  • 拿来即用,自己封装的 axios
  • Hadoop小结(下)
  • 使用老北鼻AI免费GPT对话解决gun make安装和解析iso9660的问题
  • shell脚本语句
  • 【LeetCode】2235.两整数相加
  • springboot sl4j2 写入日志到mysql