How to set frp with nginx, https(cloudflare)
Basic info
Let's say 99.88.77.66 is your server's IP address.
frp.bigbrother.com is your domain.
At the server, frps.ini
[common]
bind_port = 7000
token = bigbrotherwatchesyou
vhost_http_port = 6080
At the client, frpc.ini
[common]
server_addr = 99.88.77.66
server_port = 7000
token=bigbrotherwatchesyou
[ssh]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 2020
#this is how you connect to your local machine: ssh -oPort=2020 root@99.88.77.66
[frp]
type = http
local_ip = 127.0.0.1
local_port = 8000
custom_domains = frp.bigbrother.com
#this is how you connect to your local website: frp.bigbrother.com
At Nginx
server {
listen 80;
server_name frp.bigbrother.com;
return 301 https://frp.bigbrother.com$request_uri;
}
server {
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/frp.bigbrother.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/frp.bigbrother.com/privkey.pem; # managed by Certbot
server_name frp.bigbrother.com;
location / {
proxy_pass http://127.0.0.1:6080;
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 REMOTE-HOST $remote_addr;
add_header X-Cache $upstream_cache_status;
expires 12h;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
Set "Let's encrypt" with "Cloudflare"
I won't cover this, you have to Google it.
Do a test
0. at server: `sudo systemctl restart nginx`
1. at server: `./frps -c frps.ini`
2. at client: `./frpc -c frpc.ini`
3. at client: `python3 -m http.server 8000`
4. visit: https://frp.bigbrother.com