v2ray-core: v2ray does not read config.json from a custom path and not from a symlink either

What version of V2Ray are you using?

5.1.0

What’s your scenario of using V2Ray?

I’ve installed v2ray by using the fhs script. Initially I tried to create a symlink to /custom/path/to/config.json from /usr/local/etc/v2ray/config.json, but that didn’t work. Then I’ve created a override.conf inside the v2ray.service.d directory with below content:

[Service]
User=v2ray_user
ExecStart=
ExecStart=/usr/local/bin/v2ray run -config /custom/path/to/config.json

At first, tried without User=v2ray_user directive but didn’t work. So I created a new linux user, ran chown v2ray_user:v2ray_user config.json. But still I get permission denied:

Failed to start: main/commands: failed to load config: [/custom/path/to/config.json] > fail to load /custom/path/to/config.json: open /custom/path/to/config.json: permission denied

Had the same error with symlinks too. But interestingly, it works if I run v2ray run -config /custom/path/to/config.json in terminal or when I use User=my_own_username directive inside the override.conf

What problems have you encountered?

See above.

What’s your expectation?

I expect to be able to change to a custom path to config.json using symlinks or a .conf drop-in file.

How can one customize the path for config.json file?

Please attach your configuration here

{ can provide if absolutely needed }

Server configuration:

// Please attach your server configuration here.

Client configuration:

// Please attach your client configuration here.

Please attach error logs here

Server error log:

// Please attach your server error log here.

Client error log:

// Please attach your client error log here.

Please attach access log here

// Please attach your server access log here.

Other configurations (such as Nginx) and logs here

If V2Ray cannot start up, please attach output from --test command

If V2Ray service is abnormal, please attach journal log here

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 26 (5 by maintainers)

Most upvoted comments

@a-pav

If you don’t want to compromise the permissions of your home directory, you can use file ACL. No workaround is needed.

setfacl -m u:v2ray_user:rx <path to file or directory>

Apply this command to all parent directory of config.json. It is safe and does not affect the permissions of other users.

Works fine here. You might have wrong permission for your config file.

~/test ❯ l 
~/test ❯ l /etc/v2ray/config.json                                                                                                                                                                                                  19:54:18
Permissions Size User Date Modified    Name
.rw-r--r--  3.4k root 2022-11-16 20:02 /etc/v2ray/config.json
~/test ❯ ln -s /etc/v2ray/config.json                                                                                                                                                                                              19:54:25
~/test ❯ v2ray run -config config.json                                                                                                                                                                                             19:54:35
V2Ray 5.1.0 (V2Fly, a community-driven edition of V2Ray.) Custom (go1.19 linux/amd64)
A unified platform for anti-censorship.
2023/01/12 19:54:42 [Warning] V2Ray 5.1.0 started

You must create a new problem. May you should write a golang program to have a test?

Jan 11, 2023 19:48:02 a-pav @.***>:

Change your original file to 777

I did, it didn’t solve the issue. I even previously tried to create a new user and set ownership of the file to that user but that didn’t work either.

also needs to change the permission of the directory where the file is located to 755.

All the parent directories of my custom config.json file are set to 755 up to the user home directory.

— Reply to this email directly, view it on GitHub[https://github.com/v2fly/v2ray-core/issues/2244#issuecomment-1378630635], or unsubscribe[https://github.com/notifications/unsubscribe-auth/AKGBAYDT4XTAY7XPUWWUHZLWR2MXDANCNFSM6AAAAAATNFUFHY]. You are receiving this because you commented.[Tracking image][https://github.com/notifications/beacon/AKGBAYADDOA6H4MZABWXELDWR2MXDA5CNFSM6AAAAAATNFUFH2WGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTSSFQ56W.gif]