nginx 将http的请求转发为https

发布时间 2023-03-22 21:09:04作者: 海乐学习

使用 nginx 实现  原 http的请求 转发为 https 的请求

我使用的版本为  nginx-1.22.1

修改 nginx.conf

server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            #root   html;
            #3index  index.html index.htm;
            proxy_pass https://bjszf.zchyit.com.cn:9000;
        }

 其中

 listen 80;   被监听的端口,也可以改为其他端口
 server_name localhost;       原请求的地址

 proxy_pass https://bjaaf.bbhyit.com.cn:9000;   要转发的目标地址

测试方法

 原理就是将  http://localhost:80 的请求 转发至  https://bjaaf.bbhyit.com.cn:9000  地址上