在实际工作中,遇到一个问题:由于客户数据保密性较高,所以需要使用VPN访问其网络。为减少漏洞筛查风险,只开放了一个8080端口。
但我们部署了产品(端口为8082)和OnlyOffice插件(端口为8088),需要使用Nginx反向代理,将端口转发。
经过一段时间的摸索,终于成功配置,做一个记录。
我们的所有服务都采用docker部署,部署nginx时,将宿主机的8080端口映射到了nginx的80端口上,由于server中默认监听端口是80,因此未再配置listen。如需配置,请自行在Server下配置监听。
部署nginx语句如下:
docker run --name nginx-test -p 8080:80 -d nginx
进入nginx容器,进入/etc/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;
map $http_host $this_host {
"" $host;
default $http_host;
}
map $http_x_forwarded_proto $the_scheme {
default $http_x_forwarded_proto;
""

41

被折叠的 条评论
为什么被折叠?



