标签:file main install 容器 反向 orm search pem amp
docker search nginx
docker pull nginx:latest
docker run --name=nginx -p 443:443 -v /nginx/conf.d:/etc/nginx/conf.d -d nginx
--name=nginx: 容器名称。
-p 443:443: 端口进行映射,将本地 443 端口映射到容器内部的 443 端口。
-d nginx: 设置容器在在后台一直运行。
apt-get update && apt-get install lrzsz
apt-get update
apt-get install vim
上传根据域名生成的证书,比如 fullchain1.pem(公钥) privkey1.pem(密钥)
/etc/nginx/nginx.conf中加入如下配置:
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;
#server是新增的配置
server {
listen 443 ssl;
#server_name svr.com.cn
ssl_certificate fullchain1.pem; #公钥,证书
ssl_certificate_key privkey1.pem; #密钥
location / {
proxy_set_header X-FORWARDED-FOR $remote_addr;
proxy_set_header X-FORWARDED-PROTO $scheme;
proxy_set_header Host $http_host;
proxy_pass http://192.168.xxx.xxx:80; #代理的应用 宿主机IP:容器映射到宿主机的端口
}
}
}
service nginx reload
https://svr.com.cn
docker logs -f 09a1c
docker使用nginx实现ssl(https)反向代理其他容器应用
标签:file main install 容器 反向 orm search pem amp
原文地址:https://www.cnblogs.com/jun-zi/p/12189434.html