Skip to content

Setup FRP server on Heroku and Client on Local (Ubuntu currently). Support FRP server on Ubuntu as well and other alternatives.

Notifications You must be signed in to change notification settings

xsd871/FRP-Heroku-1

 
 

Repository files navigation

FRP Heroku

Setup FRP server on Heroku and Client on Local (Ubuntu currently). Support FRP server on Ubuntu as well and other alternatives.

Note:

Currently, we need two ports to build communication between frps and frpc, but Heroku don't support self-defined port...

Heroku (Skip this currently...)

Setup Heroku CLI

# Install on Ubuntu
sudo snap install --classic heroku

# Check Installation
heroku --version

# Login
heroku login

heroku.yml

app.json

Deploy Note

IMPORTANT: Heroku dynamically assigns your app a port, so you can't set the port to a fixed number.

Deploy Button

Dyno

Useful Command

# View logs
$ heroku logs --tail

# List the dynos for an app
$ heroku ps
Free dyno hours quota remaining this month: 550h 0m (100%)
Free dyno usage for this app: 0h 0m (0%)
For more information on dyno sleeping and how to upgrade, see:
https://devcenter.heroku.com/articles/dyno-sleeping

# If an app is down, you can restart it (assume it's web.1)
heroku restart web.1

FRP

FRP Server - Heroku

This is the server you want to use as a springboard

# Create new app
$ heroku create your-server-name
Creating ⬢ your-server-name... done
https://your-server-name.herokuapp.com/ | https://git.heroku.com/your-server-name.git

# Stack the app to `container`
heroku stack:set container
# Check current git remote
git remote -v

# Upload changes to Github
git push origin master
# Upload changes to Heroku
git push heroku master

Check the logs to see if the survice is running, and because Heroku automatically bind the port, so you may want to check the port so that you can set the frpc.ini

heroku logs --app=your-server-name

Server setting

...

If want to use the docker for Heroku outside of Heroku, remember to add -e PORT=7000 argument and open necessary ports (e.g. 7000, 6000)

FRP Client - Ubuntu

This is the computer you want to connect to

# Setup binary executables
bash get_frp_local.sh

Now you should be able to use frps and frpc.

Change settings in frpc.ini to your heroku address.

# Start client
frpc -c frpc.ini

better run with tmux

Setup Systemd Service to Auto Start on Reboot (optional but recommend)

# Copy configure file and start frpc
bash setup_frp_client_systemd.sh
# Stop service
systemctl stop frpc.service

FRP Server - Ubuntu

This is the server you want to use as a springboard

cd UbuntuFRPServer

Using Docker

# Install docker first (https://gist.github.com/daviddwlee84/9ba69aa231a19be54b6f09ae0d158683#file-install_docker-sh)
bash install_docker.sh
# Build docker image
docker build -t frp .

# Run server
docker run -d -p 7000:7000 -p 6000:6000 -p 7500:7500 frp

Using Directly

Assume you already got frps binaries, otherwise checkout here.

# Start server
frps -c frps.ini

better run with tmux

Using Systemd Service

# Copy configure file and start frps
bash setup_frp_server_systemd.sh
# Stop service
systemctl stop frps.service
# After modify /etc/frpc.ini, restart the frpc
systemctl restart frpc.service

FRP Server & Client - Windows

Make sure you have enable script executing

Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope LocalMachine (Run as administrator)

And there is potential that Windows thinks the frp*.exe is a virus. This is how to configure:

  1. Search "Virus & threat protection"
  2. Goto "Virus & threat protection settings" and click "Manage settings"
  3. Goto "Exclusions" and click "Add or remove exclusions"
  4. Add this folder (i.e. the repository directory) (because sometime it delete *.zip right away)
  5. Add "C:\frp" (default install path of my script)
# Setup binary executables & Auto run FRPC at system startup (run as administrator)
./setup_frp_windows.ps1

# Check scheduled jobs
ScheduledJob

# Unregister job
Unregister-ScheduledJob -Name FRPC


# To kill background service (run as administrator)
Get-Process frpc
Stop-Process -Id xx

How to Connect

Connect SSH

ssh -oPort=6000 username@frp-server-ip-address
# equivalent
ssh -p 6000 username@frp-server-ip-address

FRP Dashboard

If you setup with FRP Server - Ubuntu

Go to http://frp-server-ip-address:7500 and login with admin for both account and password.

FRP Setting

HTTP

must set either custom_domains or subdomain for http or https custom_domains and subdomain should set at least one of them otherwise, you can just use tcp

Use type tcp.

Or set custom_domains = { server_addr }.

Alternatives

Expose necessary port without using FRP

Ngrok

Check out here.

Applications

Other Related Network Settings

Port Forwarding

netsh

Works in Windows

# Add
netsh interface portproxy add v4tov4 listenaddress=localaddress listenport=localport connectaddress=destaddress connectport=destport
# Remove
netsh interface portproxy delete v4tov4 listenaddress=localaddress listenport=localport

INI file

(TODO) seems frp doesn't support special reference parsing

from configparser import ConfigParser, ExtendedInterpolation

config = ConfigParser(interpolation=ExtendedInterpolation())
config.read('frpc.ini')
config['http']['custom_domains']

Todo

  • Open port for other services
  • Docker for frpc?!
  • Find if there is a way to solve reference problem of frpc.ini (& http connection as well)

Resources

Example

Heroku

General

Official

Notes for Alternatives

Other Tools for Reverse Proxy / NAT Traversal / Intranet Penetration

Deploy

Other

git update-index --assume-unchanged frpc.ini

About

Setup FRP server on Heroku and Client on Local (Ubuntu currently). Support FRP server on Ubuntu as well and other alternatives.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PowerShell 37.3%
  • Shell 33.4%
  • Dockerfile 29.3%