记录nginx针对frpc的一些转发
记录nginx针对frpc的一些转发
服务器版本:debian 11
pve、openwrt通过frp内网穿透后,想进行安全访问,目前想法是nginx上配置证书进行转发
直接使用frp会把私密连接暴露在公网,安全性较差,自己用的连接建议使用vpn。
安装
详细可参考博文 https://www.myfreax.com/how-to-install-nginx-on-debian-10/
直接命令行安装
1 | 更新 |
访问 http://ip
note: 注意防火墙
nginx目录的一些说明
详细可参考博文 https://www.myfreax.com/how-to-set-up-nginx-server-blocks-on-debian-10/
个人准备在 /etc/nginx/conf.d目录下配置转发
转发内容
a.rewrite.nginx.conf80请求转4431
2
3
4
5
6
7#80重定向至https
server {
listen 80;
server_name m01.space *.m01.space *.silent.m01.space;
rewrite ^(.*)$ https://$host$1 permanent;
access_log off;
}pve.m01.space.confpve主页转发1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32# pve 管理端 pve.m01.space
server {
listen 443 ssl;
#listen [::]:443 ssl;
#配置HTTPS的默认访问端口为443。
#如果未在此处配置HTTPS的默认访问端口,可能会造成Nginx无法启动。
#如果您使用Nginx 1.15.0及以上版本,请使用listen 443 ssl代替listen 443和ssl on。
#listen 443;
#ssl on;
server_name pve.m01.space;
access_log off;
#ssl_certificate cert/7951756_m01.space.pem;
#ssl_certificate_key cert/7951756_m01.space.key;
ssl_certificate /root/.acme.sh/m01.space/fullchain.cer;
ssl_certificate_key /root/.acme.sh/m01.space/m01.space.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
#表示使用的加密套件的类型。
ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
#表示使用的TLS协议的类型,您需要自行评估是否配置TLSv1.1协议。
ssl_prefer_server_ciphers on;
location / {
proxy_pass https://127.0.0.1:8006/;
# 修改转发请求头,让8080端口的应用可以受到真实的请求
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_hide_header X-Powered-By;
}
}http.silent.m01.space.conffrpc http服务转发1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35# frpc http反向代理 *.silent.m01.space
server {
listen 443 ssl;
listen [::]:443 ssl;
#配置HTTPS的默认访问端口为443。
#如果未在此处配置HTTPS的默认访问端口,可能会造成Nginx无法启动。
#如果您使用Nginx 1.15.0及以上版本,请使用listen 443 ssl代替listen 443和ssl on。
#listen 443;
#ssl on;
server_name *.silent.m01.space;
access_log /var/log/nginx/frpc-access.log;
error_log /var/log/nginx/frpc-error.log error;
#ssl_certificate cert/7951756_m01.space.pem;
#ssl_certificate_key cert/7951756_m01.space.key;
ssl_certificate /root/.acme.sh/m01.space/fullchain.cer;
ssl_certificate_key /root/.acme.sh/m01.space/m01.space.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
#表示使用的加密套件的类型。
ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
#表示使用的TLS协议的类型,您需要自行评估是否配置TLSv1.1协议。
ssl_prefer_server_ciphers on;
location / {
#proxy_ssl_session_reuse off;ªª
proxy_pass http://127.0.0.1:7001;
# 修改转发请求头,让8080端口的应用可以受到真实的请求
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_hide_header X-Powered-By;
}
}
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Deneb!
评论





