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
Do you want to try xray? With latest code, xray should be able to read configuration from symbolic link file. But in fact, we don't have a test formally. Do you want to help to have a test?
For now I've made a shell alias to half automate the process of backing up and updating config.json using mv and cp.
To be honest, I'm a new v2ray user, still trying to wrap my mind around how it works and its configurations. So I guess it will be a while before I get to try Xray, but thanks for your work nonetheless.
It is confused. We test os.Open of golang builtin function could open symbolic link file. How could it don't read configuration?
I don't know. I haven't tested os.Open for symbolic links myself but I would generally... expect it to open symlinks too.
Maybe os.ReadLink and such methods should be used to be both clear and also "defensive" about it.
It is not necessary to change this file.
If your purpose is convenient to change the config file.
you can use the soft link.
ln -s /usr/local/etc/v2ray/config.json yourhomepath/v2fly-config.json
then, you will not enter that long path to modify the config file.
It is not necessary to change this file.
I happen to need to change config.json file quite often.
you can use the soft link.
I already tried that, it's mentioned both in the title and the first paragraph.
The problem is caused by file permission. Change your original file to 777, then the problem maybe could be solved. (golang os.Open build-in function has supported link file)
Dec 31, 2022 05:56:19 a-pav @.***>:
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[https://github.com/v2fly/fhs-install-v2ray/]. 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 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.
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
— Reply to this email directly, view it on GitHub[https://github.com/v2fly/v2ray-core/issues/2244], or unsubscribe[https://github.com/notifications/unsubscribe-auth/AKGBAYB7D4OW3IAHJMVXNMDWP5LAFANCNFSM6AAAAAATNFUFHY]. You are receiving this because you are subscribed to this thread.[Tracking image][https://github.com/notifications/beacon/AKGBAYERCSBM5SODLWGLMG3WP5LAFA5CNFSM6AAAAAATNFUFH2WGG33NNVSW45C7OR4XAZNFJFZXG5LFVJRW63LNMVXHIX3JMTHFUSYXBQ.gif]
I mean,
you can use vi soft link path to change the config file.
Don't change ExecStart to your custom path.
then you will start v2ray successfully.
btw, Linux file permission can't just change its permission, also needs to change the permission of the directory where the file is located to 755.
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.
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]
Have you tried this?
you can use vi soft link path to change the config file. Don't change ExecStart to your custom path. then you will start v2ray successfully.
What... is vi soft link path?! I used ln.
Like this: ln -sf /my/path/2/config.json /usr/local/etc/v2ray/config.json;
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
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
Seems people around here just don't bother with reading the OP anymore...
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 startedSeems people around here just don't bother with reading the OP anymore...
What I'm talking about is V2ray support both custom path and symlink. The problem you are facing is a permission issue. It's not caused by V2ray.
If you need help with configuration, it's better asking help in discussions.
What... is
vi soft link path?! I usedln. Like this:ln -sf /my/path/2/config.json /usr/local/etc/v2ray/config.json;
You can use vi /my/path/2/config.json to edit config file. I put soft link in my linux account home directory.
The log is very clear.
open /custom/path/to/config.json: permission denied
It means that the user "v2ray_user" in the systemd service file has no permission to read the "config.json".
Try to change config.json permission to "666" and make it readable by other user.
It is not wise to make the file world-writable. 644 should be enough.
It is not wise to make the file world-writable. 644 should be enough.
Yes, you're right.
It means that the user "v2ray_user" in the systemd service file has no permission to read the "config.json".
Try to change config.json permission to "666" and make it readable by other user.
In the OP I wrote:
So I created a new linux user, ran
chown v2ray_user:v2ray_user config.json. But still I get permission denied:
The config.json file is owned by v2ray_user.