【教程】nginx代理本地创建ssl链接

下载nginx:nginx: download

下载openssl:Win32/Win64 OpenSSL Installer for Windows – Shining Light Productions

安装后执行命令:

openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout cert.key -out cert.pem

生成cert.key和cert.pem

分别作为ssl_certificate_keyssl_certificate

具体操作如下图所示:

解释:

首先进入Nginx目录:H:\nginx-1.26.2

:: 进入conf目录
cd .\conf\
:: 生成ssl证书
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout cert.key -out cert.pem
:: 键入回车进入系统
:: 返回上级进入Nginx主目录
cd ..
:: 确认Ningx配置文件无问题
.\nginx.exe -t
:: 如果是successful即无问题
:: 执行Nginx
.\nginx

另外,执行完.\nginx后就可以把命令窗口关闭了,如需要停止则再执行:

.\nginx -s stop

如为fastgpt开启ssl的nginx.conf配置文件附加内容:

# ...
http {
    # ...
    server {
        listen       443 ssl;
        listen       4000 ssl;
        server_name  localhost;
        ssl_certificate      cert.pem;
        ssl_certificate_key  cert.key;

        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;
        # }

        #PROXY-CONF-START
        location ^~ / {
            proxy_pass http://127.0.0.1:3000;
            proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Real-Port $remote_port;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header X-Forwarded-Host $host;
            proxy_set_header X-Forwarded-Port $server_port;
            proxy_set_header REMOTE-HOST $remote_addr;
            
            proxy_connect_timeout 60s;
            proxy_send_timeout 600s;
            proxy_read_timeout 600s;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
      
            # 绕过SSL验证
            # proxy_ssl_verify off;
            # proxy_ssl_verify_depth 0;
        }
    }
}

启动nginx后即可用https://127.0.0.1(https://localhost)或https://127.0.0.1:4000(https://localhost:4000)访问本地http://127.0.0.1:3000上的fastgpt了。

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
Source: https://github.com/MengXi2021/Argon-Emoji-DailyNotes
Source: https://github.com/Ghost-chu/argon-huhu-emotions
https://github.com/qs5667/argon_bilibili_emoji
https://github.com/qs5667/argon_bilibili_emoji
https://github.com/qs5667/argon_bilibili_emoji
https://github.com/qs5667/argon_bilibili_emoji
Source: github.com/zhheo/Sticker-Heo
颜文字
Emoji
小恐龙
花!
每日手帐
呼呼
B站基础表情
B站节日表情
B站游戏表情
B站活动表情
Heo
上一篇
下一篇