Skip to content

Instantly share code, notes, and snippets.

@revenkroz
Last active January 17, 2024 11:32
Show Gist options
  • Save revenkroz/80a4e47f51500fe4cde16218b47bc003 to your computer and use it in GitHub Desktop.
Save revenkroz/80a4e47f51500fe4cde16218b47bc003 to your computer and use it in GitHub Desktop.
Install FRP

Server

  1. Get the binary: https://github.com/fatedier/frp/releases
  2. wget it to your directory
  3. tar -xvzf frp_0.53.2_linux_amd64.tar.gz
  4. vi frps.toml
bindAddr = "0.0.0.0"
bindPort = 27000
kcpBindPort = 27000
vhostHTTPPort = 27000
vhostHTTPSPort = 27000
auth.method = "token"
auth.token = "your-secret-pass"
subDomainHost = "dev.example.com"
custom404Page = "/var/www/html/404.html"
  1. screen -S frp
  2. ./frps -c ./frps.toml
  3. Generate manual certs for dev.example.com and *.dev.example.com
  4. Setup nginx
server {
    listen 443 ssl;

    server_name dev.example.com;

    ssl_certificate /etc/letsencrypt/live/dev.example.com-0001/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/dev.example.com-0001/privkey.pem;


    location / {
    return 404;
   }
}


server {
    listen 443 ssl;

    server_name ~^.+\.dev\.example\.com$;

    ssl_certificate /etc/letsencrypt/live/dev.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/dev.example.com/privkey.pem;

    location = /robots.txt {
        return 200 "User-agent: *\nDisallow: /\n";
    }

    location / {
       proxy_pass       http://127.0.0.1:27000/;
       proxy_http_version 1.1;
       proxy_set_header Upgrade $http_upgrade;
       proxy_set_header Connection "upgrade";
       proxy_set_header host $host;
       proxy_set_header X-real-ip $remote_addr;
       proxy_set_header X-forward-for $proxy_add_x_forwarded_for;
       proxy_set_header X-Forwarded-Proto https;
       proxy_buffering  off;
       proxy_redirect   off;
   }

}

Client

  1. wget
  2. cp frp_0.53.2_darwin_arm64/frpc /usr/local/bin/
  3. Create frpc.toml
loginFailExit = false
transport.tls.enable = false

auth.method = "token"
auth.token = "your-secret-pass"
serverAddr = "127.0.0.1"
serverPort = 27000

[[proxies]]
name = "web"
type = "http"
localIP = "localhost"
localPort = 3333
subdomain = "custom-subdomain"
  1. frpc -c deploy/proxy/frpc.toml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment