Nginx代理本地exe服务http为https

Nginx代理本地exe服务http为https

下载Nginx

点击下载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;
    #    }
    #}

}
相关推荐
友友马24 分钟前
『 Linux 』高级IO (二) - 多路转接
linux·运维·服务器
运维搬运工6 小时前
nginx
运维·nginx
ChineHe6 小时前
nginx基础篇 - 入门介绍与安装教程
运维·nginx
嗑瓜子儿溜茶水儿6 小时前
docker 部署 NginX
nginx·docker·容器
小白爱电脑8 小时前
光纤收发器技术参数详解
运维·网络·光纤收发
桃园码工8 小时前
11-Gin 中的 Cookie --[Gin 框架入门精讲与实战案例]
运维·服务器·gin·实战案例·入门精讲
优雅孤狼8 小时前
Ansible Jinja2 语法简介及使用
运维·ansible
一二小选手9 小时前
【Nginx】Nginx代理模式相关概念解释及Nginx安装
java·nginx·代理模式
winstongit9 小时前
SSH多秘钥管理
运维·ssh
ueanaIU潇潇子10 小时前
Linux系统安装es详细教程
linux·运维·elasticsearch