use nixos module to configure frp

This commit is contained in:
Adithya 2023-10-08 17:46:11 +05:30
parent 9b8ec24c63
commit 56151e5f52
Signed by: adtya
GPG key ID: 48FC9915FFD326D0
2 changed files with 84 additions and 89 deletions

View file

@ -5,44 +5,40 @@
}: let
inherit (secrets) frp_config;
in {
systemd.services.frpc = {
services.frp = {
enable = true;
description = "FRP Client";
after = ["network.target"];
requires = ["network.target"];
wantedBy = ["multi-user.target"];
serviceConfig = {
Type = "simple";
ExecStart = "${pkgs.frp}/bin/frpc -c /etc/frp/frpc.ini";
Restart = "always";
RestartSec = "5s";
role = "client";
settings = {
common = {
server_addr = "${frp_config.ip}";
server_port = 7000;
authentication_method = "token";
token = "${frp_config.token}";
};
"ssh.rico1" = {
type = "tcp";
local_port = 22;
remote_port = 6001;
};
"http.matrix.adtya.xyz" = {
type = "http";
custom_domains = "matrix.adtya.xyz";
local_port = 80;
};
"https.matrix.adtya.xyz" = {
type = "https";
custom_domains = "matrix.adtya.xyz";
local_port = 443;
};
"https.matrix.adtya.xyz.8448" = {
type = "tcp";
local_port = 8448;
remote_port = 8448;
};
};
};
environment.etc."frp/frpc.ini".text = ''
[common]
server_addr = "${frp_config.ip}"
server_port = 7000
authentication_method = token
token = "${frp_config.token}"
[ssh.rico1]
type = tcp
local_port = 22
remote_port = 6001
[http.matrix.adtya.xyz]
type = http
custom_domains = matrix.adtya.xyz
local_port = 80
[https.matrix.adtya.xyz]
type = https
custom_domains = matrix.adtya.xyz
local_port = 443
[https.matrix.adtya.xyz.8448]
type = tcp
local_port = 8448
remote_port = 8448
'';
}

View file

@ -5,59 +5,58 @@
}: let
inherit (secrets) frp_config;
in {
systemd.services.frpc = {
services.frp = {
enable = true;
description = "FRP Client";
after = ["network.target"];
requires = ["network.target"];
wantedBy = ["multi-user.target"];
serviceConfig = {
Type = "simple";
ExecStart = "${pkgs.frp}/bin/frpc -c /etc/frp/frpc.ini";
Restart = "always";
RestartSec = "5s";
role = "client";
settings = {
"common" = {
server_addr = "${frp_config.ip}";
server_port = 7000;
authentication_method = "token";
token = "${frp_config.token}";
};
"ssh.rico2" = {
type = "tcp";
local_port = 22;
remote_port = 6002;
};
"http.adtya.xyz" = {
type = "http";
custom_domains = "adtya.xyz";
local_port = 80;
};
"https.adtya.xyz" = {
type = "https";
custom_domains = "adtya.xyz";
local_port = 443;
};
"http.www.adtya.xyz" = {
type = "http";
custom_domains = "www.adtya.xyz";
local_port = 80;
};
"https.www.adtya.xyz" = {
type = "https";
custom_domains = "www.adtya.xyz";
local_port = 443;
};
"http.proofs.adtya.xyz" = {
type = "http";
custom_domains = "proofs.adtya.xyz";
local_port = 80;
};
"https.proofs.adtya.xyz" = {
type = "https";
custom_domains = "proofs.adtya.xyz";
local_port = 443;
};
};
};
environment.etc."frp/frpc.ini".text = ''
[common]
server_addr = "${frp_config.ip}"
server_port = 7000
authentication_method = token
token = "${frp_config.token}"
[ssh.rico2]
type = tcp
local_port = 22
remote_port = 6002
[http.adtya.xyz]
type = http
custom_domains = adtya.xyz
local_port = 80
[https.adtya.xyz]
type = https
custom_domains = adtya.xyz
local_port = 443
[http.www.adtya.xyz]
type = http
custom_domains = www.adtya.xyz
local_port = 80
[https.www.adtya.xyz]
type = https
custom_domains = www.adtya.xyz
local_port = 443
[http.proofs.adtya.xyz]
type = http
custom_domains = proofs.adtya.xyz
local_port = 80
[https.proofs.adtya.xyz]
type = https
custom_domains = proofs.adtya.xyz
local_port = 443
'';
}