惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

K
Kaspersky official blog
Martin Fowler
Martin Fowler
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
V
Visual Studio Blog
博客园_首页
Engineering at Meta
Engineering at Meta
The Cloudflare Blog
MongoDB | Blog
MongoDB | Blog
Blog — PlanetScale
Blog — PlanetScale
T
The Blog of Author Tim Ferriss
雷峰网
雷峰网
D
Docker
博客园 - 司徒正美
S
SegmentFault 最新的问题
M
MIT News - Artificial intelligence
博客园 - 叶小钗
博客园 - 三生石上(FineUI控件)
U
Unit 42
J
Java Code Geeks
A
About on SuperTechFans
N
Netflix TechBlog - Medium
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
Security Affairs
I
Intezer
Cisco Talos Blog
Cisco Talos Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
B
Blog RSS Feed
P
Privacy & Cybersecurity Law Blog
T
Tenable Blog
T
Threatpost
H
Hacker News: Front Page
G
Google Developers Blog
博客园 - 【当耐特】
Hugging Face - Blog
Hugging Face - Blog
Apple Machine Learning Research
Apple Machine Learning Research
L
Lohrmann on Cybersecurity
大猫的无限游戏
大猫的无限游戏
Google DeepMind News
Google DeepMind News
A
Arctic Wolf
S
Secure Thoughts
GbyAI
GbyAI
NISL@THU
NISL@THU
S
Security @ Cisco Blogs
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Webroot Blog
Webroot Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
O
OpenAI News
Spread Privacy
Spread Privacy
Application and Cybersecurity Blog
Application and Cybersecurity Blog

思有云 - IOIOX - 内网穿透

群晖NAS反向代理 + 内网穿透 = 无需端口访问内网所有服务无需端口 - 思有云 群晖NAS内网穿透各套件独立门户系列教程 - Drive - 思有云 群晖NAS内网穿透各套件独立门户系列教程 - File Station - 思有云 群晖NAS高级服务 - WordPress 配置内网穿透无端口访问教程 - 思有云 群晖NAS使用 docker 部署 frps 实现直连内网远程办公 - 思有云 新手入门 - 详解 frp 内网穿透 frpc.ini 配置 - 思有云 解决群晖NAS内网穿透后移动端DS File无法连接的问题 - 思有云 - IOIOX 群晖NAS内网穿透各套件独立门户系列教程 - Docker应用 - 思有云 群晖NAS内网穿透各套件独立门户系列教程 - Moments - 思有云
宝塔面板配置 Nginx 和 frps 共存 80/443 端口及泛域名支持教程 - 思有云
博主: Stille · 2020-04-28 · via 思有云 - IOIOX - 内网穿透
  • 发布时间:
  • 29103 次浏览
  • 16 条评论
  • 3645字数
  • 分类: 技术教程
  1. 首页
  2. 正文  

前言

本站之前介绍过在LNMP环境下的 nginx 和 frps 共存配置教程,不过也有小伙伴咨询宝塔面板上配置的方法.鉴于大部分小伙伴只一台服务器,并且已经部署过网站,想同时使用 frps 服务,本文将介绍在宝塔面板的 LNMP 环境来配置 nginx 和 frps 共存 80/443 端口及泛域名支持的方法.

本文为 Stille 原创文章.经实践,测试,整理发布.如需转载请联系作者获得授权,并注明转载地址.

  

配置流程

宝塔面板 nginx 配置

按照常规方法安装宝塔面板,并在宝塔面板上安装LNMP环境.尝试添加一个网站确保服务能正常运行.如果已有网站正常运行,可以忽略此步.

查询 nginx 配置文件

宝塔面板的nginx主配置文件所在目录为/www/server/nginx/conf

常规情况下并不会修改默认配置文件,可以执行以下命令查看include的目录.

cat /www/server/nginx/conf/nginx.conf

默认配置中显示include的目录为/www/server/panel/vhost/nginx,即在此目录下的conf文件也可以被 nginx 使用.宝塔面板上创建的网站域名配置文件也在此目录.

查询站点目录

进入/www/server/panel/vhost/nginx目录可以看出之前创建的test.ioiox.com的配置文件也在此.

提前配置证书

证书文件可以手动上传,也可以使用已运行的网站证书,其目录为/www/server/panel/vhost/cert.

创建 frps.conf

在上文查询的站点目录创建frps.conf配置文件

vi /www/server/panel/vhost/nginx/frps.conf

参考以下配置文件,注意修改域名,证书路径反代端口,本文以1234为例.

server {
    listen 80;
    server_name *.yourdomain.com;
#    return 301 https://$host$request_uri;

    location / {
        proxy_pass http://127.0.0.1:1234;
        proxy_redirect http://$host/ http://$http_host/;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
    }
}

server {
    listen 443 ssl http2;
    server_name *.yourdomain.com;

    ssl_certificate /www/server/panel/vhost/cert/yourdomain.crt;
    ssl_certificate_key /www/server/panel/vhost/cert/yourdomain.key;

    client_max_body_size 50m; 
    client_body_buffer_size 256k;
    client_header_timeout 3m;
    client_body_timeout 3m;
    send_timeout 3m;
    proxy_connect_timeout 300s; 
    proxy_read_timeout 300s; 
    proxy_send_timeout 300s;
    proxy_buffer_size 64k; 
    proxy_buffers 4 32k; 
    proxy_busy_buffers_size 64k;
    proxy_temp_file_write_size 64k; 
    proxy_ignore_client_abort on; 

    location / {
        proxy_pass http://127.0.0.1:1234;
        proxy_redirect https://$host/ https://$http_host/;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_ssl_server_name on;
        proxy_set_header Host $host;
    }
}

frp 配置

frps.ini

由于 nginx 占用80/443端口,frps.ini中的vhost_http_portvhost_https_port需修改为其他端口,本文以12345678为例.

frpc.ini

如果 frps.ini 配置了 subdomain_host 泛域名,那么 frpc.ini 中域名参数需使用 subdomain = xx 仅填写二级域名主机头即可,不要填写完整域名.

如果 frps.ini 没有配置 subdomain_host泛域名,那么 frpc.ini 中域名参数需使用 custom_domains = xx.xxx.com 需填写完整的域名.

  

结语

感谢在上文中的网友留言给出了宝塔面板上的共存解决方案.

更多FRP内网穿透相关技巧,教程及信息,请持续关注本站FRP内网穿透专栏:


晚高峰稳定 4K 的 IPLC 机场 解锁各流媒体 支持 ChatGPT. 晚高峰稳定 4K 的 IPLC 机场 解锁各流媒体 支持 ChatGPT. RedteaGO - 最划算的大陆漫游 eSim 流量卡,原生境外 IP,注册就送 3 刀。
RedteaGO - 最划算的大陆漫游 eSim 流量卡,原生境外 IP,注册就送 3 刀。

赞赏作者

如果喜欢我的文章,觉得对你有帮助,请随意赞赏!

宝塔面板配置 Nginx 和 frps 共存 80/443 端口及泛域名支持教程

 •