100 lines
2.6 KiB
Markdown
Raw Normal View History

# Configure and Run
2021-05-26 19:05:53 +08:00
After [downloading and installing Xray](./install/), you need to configure it,
2021-05-26 19:05:53 +08:00
For demonstration, only a simple configuration method is introduced here. More templates: [Xray-examples](https://github.com/XTLS/Xray-examples)
2021-05-26 19:05:53 +08:00
If you need to configure more complex functions, please refer to the relevant instructions in the more detailed [configuration file](../config/).
2021-05-26 19:05:53 +08:00
## Server Configuration
2021-05-26 19:05:53 +08:00
You need a server outside the firewall to run server-side Xray. The configuration is as follows:
2021-05-26 19:05:53 +08:00
```json
{
"inbounds": [
{
"port": 10086, // server listening port
2021-05-26 19:05:53 +08:00
"protocol": "vmess",
"settings": {
"clients": [
{
"id": "b831381d-6324-4d53-ad4f-8cda48b30811"
}
]
}
}
],
"outbounds": [
{
"protocol": "freedom"
}
]
}
```
In the configuration of the server, you need to ensure `id` that the and port are consistent with the client, and then you can connect normally.
2021-05-26 19:05:53 +08:00
## Client Configuration
2021-05-26 19:05:53 +08:00
On your PC (or phone), you need to run Xray with the following configuration:
2021-05-26 19:05:53 +08:00
```json
{
"inbounds": [
{
"port": 1080, // SOCKS proxy port, the proxy needs to be configured in the browser and point to this port
2021-05-26 19:05:53 +08:00
"listen": "127.0.0.1",
"protocol": "socks",
"settings": {
"udp": true
}
}
],
"outbounds": [
{
"protocol": "vmess",
"settings": {
"vnext": [
{
"address": "server", // Server address, please change it to your own server IP or domain name
"port": 10086, // server port
2021-05-26 19:05:53 +08:00
"users": [
{
"id": "b831381d-6324-4d53-ad4f-8cda48b30811"
}
]
}
]
}
},
{
"protocol": "freedom",
"tag": "direct"
}
],
"routing": {
"domainStrategy": "IPOnDemand",
"rules": [
{
"type": "field",
"ip": ["geoip:private"],
"outboundTag": "direct"
}
]
}
}
```
The only thing to change in the above configuration is your server IP, which is noted in the configuration. The above configuration will forward all traffic to your server except on the LAN (such as the access router).
2021-05-26 19:05:53 +08:00
## Run
2021-05-26 19:05:53 +08:00
- On Windows and macOS, configuration files are usually `config.json`
- Just run `Xray` or `Xray.exe`
- On Linux, configuration files are usually located in `/etc/xray/` or `/usr/local/etc/xray/`.
- Run `xray run -c /etc/xray/config.json`
- Or use something like systemd to run Xray as a service in the background.
2021-05-26 19:05:53 +08:00
2023-03-08 01:03:19 -05:00
For more detailed instructions, please refer to [Configuration](../config/) Document and [小小白话文](./level-0/).