Nginx代理本地exe服务http为https
下载Nginx
下载好之后是一个压缩包,解压放到没有中文的路径下就可以了
Nginx命令
调出cmd窗口cd到安装路径
输入:nginx -v 查看版本
powershell
nginx -h:查看帮助
nginx -v:查看nginx的版本
start nginx 启动
nginx -s reload 加载新配置重启
nginx -s quit 关闭
nginx -t 检查配置文件是否有语法错误
exe服务http代理为https
找到conf文件夹下的nginx.conf文件
csharp
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 10240;
}
http {
include 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 logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
#代理的服务1 资源服
upstream vr-ziyuan {
#ip_hash;
server 127.0.0.1:8088 weight=1;
}
#代理的服务2 逻辑服
upstream vr-luoji {
#ip_hash;
server 127.0.0.1:8081 weight=1;
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
server {
listen 端口号 ssl;
server_name 要代理输出的域名;
ssl_certificate 域名文件存放地址.com.pem;
ssl_certificate_key 域名文件存放地址.com.key;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
location / {
proxy_pass http://vr-ziyuan;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
server {
listen 端口号 ssl;
server_name 要代理输出的域名;
ssl_certificate 域名文件存放地址.com.pem;
ssl_certificate_key 域名文件存放地址.com.key;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
location / {
proxy_pass http://IP:端口;#逻辑服的IP:端口,逻辑服是WebSocket
proxy_read_timeout 600s;
proxy_send_timeout 600s;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
}
}
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}