[GH-ISSUE #3276] 使用systemctl运行frps时,不会根据frps的.ini配置文件在log_file下输出日志。frpc同样如此。 #2625

Closed
opened 2026-05-05 13:41:36 -06:00 by gitea-mirror · 8 comments
Owner

Originally created by @JasonJarvan on GitHub (Jan 28, 2023).
Original GitHub issue: https://github.com/fatedier/frp/issues/3276

Bug Description

当我使用systemctl 运行 frp时,

frpc Version

0.46.1

frps Version

0.46.0

System Architecture

服务端和客户端都是Linux

Configurations

因为我猜测frps 和 frpc不输出日志的原因相同,所以我先给出frps的配置。如果frpc的配置也需要,可以在后面要求。

frps.ini

[common] bind_addr = 0.0.0.0 bind_port = 10086 tls_enable = true kcp_bind_port = 10086 bind_udp_port = 10087 vhost_http_port = 80 vhost_http_port = 8080 vhost_https_port = 443 log_file = ./frps.log log_level = info log_max_days = 3 max_pool_count = 50 tcp_mux = true

systemd/system/frps.service

`
[Unit]
Description=The nginx HTTP and reverse proxy server
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=simple
ExecStart=/usr/local/frps/frps -c /usr/local/frps/frps.ini
KillSignal=SIGQUIT
TimeoutStopSec=5
KillMode=process
PrivateTmp=true
StandardOutput=syslog
StandardError=inherit

[Install]
WantedBy=multi-user.target
`

然后执行systemctl enable frps
systemctl start frps
systemctl status frps,
在status 的输出中没有frps运行时日志,只有守护进程的日志。在log_file指定的目录下不会输出frps.log 。journalctl -u frps的输出也是一样。

status输出如下:

`● frps.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/frps.service; enabled; vendor preset: disabled)
Active: active (running) since Sat 2023-01-28 21:28:10 CST; 4s ago
Main PID: 24939 (frps)
CGroup: /system.slice/frps.service
└─24939 /usr/local/frps/frps -c /usr/local/frps/frps.ini

Jan 28 21:28:10 VM-12-3-centos systemd[1]: Started The nginx HTTP and reverse proxy server`

但是,我关闭systemctl 的frps,仅通过 ./frps -C ./frps.ini 命令跑frps,是能正常输出日志的,日志如下:
2023/01/28 21:27:00 [I] [tcp.go:64] [1e09032279b617c3] [ssh] tcp proxy listen port [55522] 2023/01/28 21:27:00 [I] [control.go:464] [1e09032279b617c3] new proxy [ssh] type [tcp] success 2023/01/28 21:27:00 [I] [control.go:464] [1e09032279b617c3] new proxy [p2p_ssh] type [xtcp] success 2023/01/28 21:27:00 [I] [http.go:93] [1e09032279b617c3] [web] http proxy listen for host [cdn.74a.cn] location [/clash] group [], routeByHTTPUser [] 2023/01/28 21:27:00 [I] [control.go:464] [1e09032279b617c3] new proxy [web] type [http] success

Logs

No response

Steps to reproduce

...

Affected area

  • Docs
  • Installation
  • Performance and Scalability
  • Security
  • User Experience
  • Test and Release
  • Developer Infrastructure
  • Client Plugin
  • Server Plugin
  • Extensions
  • Others
Originally created by @JasonJarvan on GitHub (Jan 28, 2023). Original GitHub issue: https://github.com/fatedier/frp/issues/3276 ### Bug Description 当我使用systemctl 运行 frp时, ### frpc Version 0.46.1 ### frps Version 0.46.0 ### System Architecture 服务端和客户端都是Linux ### Configurations 因为我猜测frps 和 frpc不输出日志的原因相同,所以我先给出frps的配置。如果frpc的配置也需要,可以在后面要求。 > frps.ini `[common] bind_addr = 0.0.0.0 bind_port = 10086 tls_enable = true kcp_bind_port = 10086 bind_udp_port = 10087 vhost_http_port = 80 vhost_http_port = 8080 vhost_https_port = 443 log_file = ./frps.log log_level = info log_max_days = 3 max_pool_count = 50 tcp_mux = true` >systemd/system/frps.service ` [Unit] Description=The nginx HTTP and reverse proxy server After=network.target remote-fs.target nss-lookup.target [Service] Type=simple ExecStart=/usr/local/frps/frps -c /usr/local/frps/frps.ini KillSignal=SIGQUIT TimeoutStopSec=5 KillMode=process PrivateTmp=true StandardOutput=syslog StandardError=inherit [Install] WantedBy=multi-user.target ` 然后执行systemctl enable frps systemctl start frps systemctl status frps, 在status 的输出中没有frps运行时日志,只有守护进程的日志。在log_file指定的目录下不会输出frps.log 。journalctl -u frps的输出也是一样。 > status输出如下: `● frps.service - The nginx HTTP and reverse proxy server Loaded: loaded (/usr/lib/systemd/system/frps.service; enabled; vendor preset: disabled) Active: active (running) since Sat 2023-01-28 21:28:10 CST; 4s ago Main PID: 24939 (frps) CGroup: /system.slice/frps.service └─24939 /usr/local/frps/frps -c /usr/local/frps/frps.ini Jan 28 21:28:10 VM-12-3-centos systemd[1]: Started The nginx HTTP and reverse proxy server` 但是,我关闭systemctl 的frps,仅通过 `./frps -C ./frps.ini `命令跑frps,是能正常输出日志的,日志如下: `2023/01/28 21:27:00 [I] [tcp.go:64] [1e09032279b617c3] [ssh] tcp proxy listen port [55522] 2023/01/28 21:27:00 [I] [control.go:464] [1e09032279b617c3] new proxy [ssh] type [tcp] success 2023/01/28 21:27:00 [I] [control.go:464] [1e09032279b617c3] new proxy [p2p_ssh] type [xtcp] success 2023/01/28 21:27:00 [I] [http.go:93] [1e09032279b617c3] [web] http proxy listen for host [cdn.74a.cn] location [/clash] group [], routeByHTTPUser [] 2023/01/28 21:27:00 [I] [control.go:464] [1e09032279b617c3] new proxy [web] type [http] success` ### Logs _No response_ ### Steps to reproduce 1. 2. 3. ... ### Affected area - [ ] Docs - [ ] Installation - [ ] Performance and Scalability - [ ] Security - [ ] User Experience - [X] Test and Release - [ ] Developer Infrastructure - [ ] Client Plugin - [ ] Server Plugin - [ ] Extensions - [ ] Others
Author
Owner

@Becods commented on GitHub (Jan 28, 2023):

frpc.conf 中的路径要使用绝对路径

或者 systemd 加上WorkingDirectory

<!-- gh-comment-id:1407417063 --> @Becods commented on GitHub (Jan 28, 2023): frpc.conf 中的路径要使用绝对路径 或者 systemd 加上`WorkingDirectory`
Author
Owner

@JasonJarvan commented on GitHub (Jan 28, 2023):

frpc.conf 中的路径要使用绝对路径

@Becods frpc.conf是指frps.ini吗?

或者 systemd 加上WorkingDirectory

这里是指frps.service文件中加WorkingDirectory吗?

<!-- gh-comment-id:1407417788 --> @JasonJarvan commented on GitHub (Jan 28, 2023): > frpc.conf 中的路径要使用绝对路径 @Becods frpc.conf是指frps.ini吗? >或者 systemd 加上WorkingDirectory 这里是指frps.service文件中加WorkingDirectory吗?
Author
Owner

@Becods commented on GitHub (Jan 28, 2023):

frpc.conf 中的路径要使用绝对路径

@Becods frpc.conf是指frps.ini吗?

或者 systemd 加上WorkingDirectory

这里是指frps.service文件中加WorkingDirectory吗?

...
vhost_https_port = 443
log_file = /var/logs/frps.log
log_level = info
...

或者

...
[Service]
WorkingDirectory=/var/logs
ExecStart=/usr/local/frps/frps -c /usr/local/frps/frps.ini
...
<!-- gh-comment-id:1407418993 --> @Becods commented on GitHub (Jan 28, 2023): > > frpc.conf 中的路径要使用绝对路径 > > @Becods frpc.conf是指frps.ini吗? > > > 或者 systemd 加上WorkingDirectory > > 这里是指frps.service文件中加WorkingDirectory吗? <pre><code>... vhost_https_port = 443 log_file = <strong>/var/logs</strong>/frps.log log_level = info ... </code></pre> 或者 <pre><code>... [Service] <strong>WorkingDirectory=/var/logs</strong> ExecStart=/usr/local/frps/frps -c /usr/local/frps/frps.ini ... </code></pre>
Author
Owner

@JasonJarvan commented on GitHub (Jan 28, 2023):

@Becods 感谢!第一种方法有效!
第二种我也在客户端试了,我保留了frpc.ini中的log_file=./frpc.log, 并在 systemd 加上WorkingDirectory。但是sudo systemctl restart frpc后提示:

Jan 28 23:34:55 frpc[1247099]: logs.BeeLogger.SetLogger: open /usr/local/etc/frp/frpc.log: permission denied

我尝试过了sudo chmod 700 frpc,给frpc赋权。但是无效。请问怎么解决?

我刚刚用sudo chmod 666 frpc.log 将frpc.log文件降权,就OK了。谢谢你!

<!-- gh-comment-id:1407424309 --> @JasonJarvan commented on GitHub (Jan 28, 2023): @Becods 感谢!第一种方法有效! 第二种我也在客户端试了,我保留了frpc.ini中的log_file=./frpc.log, 并在 systemd 加上WorkingDirectory。但是`sudo systemctl restart frpc`后提示: >Jan 28 23:34:55 frpc[1247099]: logs.BeeLogger.SetLogger: open /usr/local/etc/frp/frpc.log: permission denied 我尝试过了sudo chmod 700 frpc,给frpc赋权。但是无效。请问怎么解决? 我刚刚用sudo chmod 666 frpc.log 将frpc.log文件降权,就OK了。谢谢你!
Author
Owner

@ylluminate commented on GitHub (Feb 1, 2023):

Have tried both methods, but unfortunately neither work out. I still continue to get:

frps[6547]: logs.BeeLogger.SetLogger: open /opt/frp/frp_current/frps.log: read-only file system

Ideally I'd like to get the log to be in the /opt/frp/frp_current/ path, but this is a tough nut to crack here.

Can we get a more specific example of working settings for both the frps.ini and the /usr/lib/systemd/system/frps.service file for Ubuntu 22.04?

<!-- gh-comment-id:1411583199 --> @ylluminate commented on GitHub (Feb 1, 2023): Have tried both methods, but unfortunately neither work out. I still continue to get: ``` frps[6547]: logs.BeeLogger.SetLogger: open /opt/frp/frp_current/frps.log: read-only file system ``` Ideally I'd like to get the log to be in the `/opt/frp/frp_current/` path, but this is a tough nut to crack here. Can we get a more specific example of working settings for both the `frps.ini` and the `/usr/lib/systemd/system/frps.service` file for Ubuntu 22.04?
Author
Owner

@JasonJarvan commented on GitHub (Feb 13, 2023):

Since the error is read-only file system, I guess the reason is you have set the .log file read-only.

<!-- gh-comment-id:1428373091 --> @JasonJarvan commented on GitHub (Feb 13, 2023): Since the error is read-only file system, I guess the reason is you have set the .log file read-only.
Author
Owner

@ylluminate commented on GitHub (Feb 13, 2023):

In this situation the filesystem is not read-only, but rather I suspect a problem with initiation/execution of the program by a user that does not have permission to the folder. The problem is that even when I attempt to execute this as root for diagnostics, I still am being told the same thing - which is nonsensical. It appears that some additional debugging/logging of the logging facilitate needs to be put into place by @fatedier on their "BeeLogger" library.

Also, @fatedier I would highly suggest changing the "Bee" naming of this since it is attached to spyware and was alarming while initially trying to do research on it.

<!-- gh-comment-id:1428412280 --> @ylluminate commented on GitHub (Feb 13, 2023): In this situation the filesystem is not read-only, but rather I suspect a problem with initiation/execution of the program by a user that does not have permission to the folder. The problem is that even when I attempt to execute this as `root` for diagnostics, I still am being told the same thing - which is nonsensical. It appears that some additional debugging/logging of the logging facilitate needs to be put into place by @fatedier on their "BeeLogger" library. Also, @fatedier I would highly suggest changing the "Bee" naming of this since it is attached to spyware and was alarming while initially trying to do research on it.
Author
Owner

@cvpas commented on GitHub (Mar 29, 2023):

Bug Description

当我使用systemctl 运行 frp时,

frpc Version

0.46.1

frps Version

0.46.0

System Architecture

服务端和客户端都是Linux

Configurations

因为我猜测frps 和 frpc不输出日志的原因相同,所以我先给出frps的配置。如果frpc的配置也需要,可以在后面要求。

frps.ini

[common] bind_addr = 0.0.0.0 bind_port = 10086 tls_enable = true kcp_bind_port = 10086 bind_udp_port = 10087 vhost_http_port = 80 vhost_http_port = 8080 vhost_https_port = 443 log_file = ./frps.log log_level = info log_max_days = 3 max_pool_count = 50 tcp_mux = true

systemd/system/frps.service

` [Unit] Description=The nginx HTTP and reverse proxy server After=network.target remote-fs.target nss-lookup.target

[Service] Type=simple ExecStart=/usr/local/frps/frps -c /usr/local/frps/frps.ini KillSignal=SIGQUIT TimeoutStopSec=5 KillMode=process PrivateTmp=true StandardOutput=syslog StandardError=inherit

[Install] WantedBy=multi-user.target `

然后执行systemctl enable frps systemctl start frps systemctl status frps, 在status 的输出中没有frps运行时日志,只有守护进程的日志。在log_file指定的目录下不会输出frps.log 。journalctl -u frps的输出也是一样。

status输出如下:

`● frps.service - The nginx HTTP and reverse proxy server Loaded: loaded (/usr/lib/systemd/system/frps.service; enabled; vendor preset: disabled) Active: active (running) since Sat 2023-01-28 21:28:10 CST; 4s ago Main PID: 24939 (frps) CGroup: /system.slice/frps.service └─24939 /usr/local/frps/frps -c /usr/local/frps/frps.ini

Jan 28 21:28:10 VM-12-3-centos systemd[1]: Started The nginx HTTP and reverse proxy server`

但是,我关闭systemctl 的frps,仅通过 ./frps -C ./frps.ini 命令跑frps,是能正常输出日志的,日志如下: 2023/01/28 21:27:00 [I] [tcp.go:64] [1e09032279b617c3] [ssh] tcp proxy listen port [55522] 2023/01/28 21:27:00 [I] [control.go:464] [1e09032279b617c3] new proxy [ssh] type [tcp] success 2023/01/28 21:27:00 [I] [control.go:464] [1e09032279b617c3] new proxy [p2p_ssh] type [xtcp] success 2023/01/28 21:27:00 [I] [http.go:93] [1e09032279b617c3] [web] http proxy listen for host [cdn.74a.cn] location [/clash] group [], routeByHTTPUser [] 2023/01/28 21:27:00 [I] [control.go:464] [1e09032279b617c3] new proxy [web] type [http] success

Logs

No response

Steps to reproduce

...

Affected area

  • Docs
  • Installation
  • Performance and Scalability
  • Security
  • User Experience
  • Test and Release
  • Developer Infrastructure
  • Client Plugin
  • Server Plugin
  • Extensions
  • Others

日志文件路径写/var/log/frp.log试试,另外systemd service文件中不要写user这一行。

<!-- gh-comment-id:1488709795 --> @cvpas commented on GitHub (Mar 29, 2023): > ### Bug Description > 当我使用systemctl 运行 frp时, > > ### frpc Version > 0.46.1 > > ### frps Version > 0.46.0 > > ### System Architecture > 服务端和客户端都是Linux > > ### Configurations > 因为我猜测frps 和 frpc不输出日志的原因相同,所以我先给出frps的配置。如果frpc的配置也需要,可以在后面要求。 > > > frps.ini > > `[common] bind_addr = 0.0.0.0 bind_port = 10086 tls_enable = true kcp_bind_port = 10086 bind_udp_port = 10087 vhost_http_port = 80 vhost_http_port = 8080 vhost_https_port = 443 log_file = ./frps.log log_level = info log_max_days = 3 max_pool_count = 50 tcp_mux = true` > > > systemd/system/frps.service > > ` [Unit] Description=The nginx HTTP and reverse proxy server After=network.target remote-fs.target nss-lookup.target > > [Service] Type=simple ExecStart=/usr/local/frps/frps -c /usr/local/frps/frps.ini KillSignal=SIGQUIT TimeoutStopSec=5 KillMode=process PrivateTmp=true StandardOutput=syslog StandardError=inherit > > [Install] WantedBy=multi-user.target ` > > 然后执行systemctl enable frps systemctl start frps systemctl status frps, 在status 的输出中没有frps运行时日志,只有守护进程的日志。在log_file指定的目录下不会输出frps.log 。journalctl -u frps的输出也是一样。 > > > status输出如下: > > `● frps.service - The nginx HTTP and reverse proxy server Loaded: loaded (/usr/lib/systemd/system/frps.service; enabled; vendor preset: disabled) Active: active (running) since Sat 2023-01-28 21:28:10 CST; 4s ago Main PID: 24939 (frps) CGroup: /system.slice/frps.service └─24939 /usr/local/frps/frps -c /usr/local/frps/frps.ini > > Jan 28 21:28:10 VM-12-3-centos systemd[1]: Started The nginx HTTP and reverse proxy server` > > 但是,我关闭systemctl 的frps,仅通过 `./frps -C ./frps.ini `命令跑frps,是能正常输出日志的,日志如下: `2023/01/28 21:27:00 [I] [tcp.go:64] [1e09032279b617c3] [ssh] tcp proxy listen port [55522] 2023/01/28 21:27:00 [I] [control.go:464] [1e09032279b617c3] new proxy [ssh] type [tcp] success 2023/01/28 21:27:00 [I] [control.go:464] [1e09032279b617c3] new proxy [p2p_ssh] type [xtcp] success 2023/01/28 21:27:00 [I] [http.go:93] [1e09032279b617c3] [web] http proxy listen for host [cdn.74a.cn] location [/clash] group [], routeByHTTPUser [] 2023/01/28 21:27:00 [I] [control.go:464] [1e09032279b617c3] new proxy [web] type [http] success` > > ### Logs > _No response_ > > ### Steps to reproduce > > ... > > ### Affected area > * [ ] Docs > * [ ] Installation > * [ ] Performance and Scalability > * [ ] Security > * [ ] User Experience > * [x] Test and Release > * [ ] Developer Infrastructure > * [ ] Client Plugin > * [ ] Server Plugin > * [ ] Extensions > * [ ] Others 日志文件路径写/var/log/frp.log试试,另外systemd service文件中不要写user这一行。
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/frp#2625
No description provided.