侧边栏壁纸
博主头像
MicroMatrix博主等级

曲则全,枉则直,洼则盈,敝则新,少则得,多则惑。是以圣人抱一为天下式。不自见,故明;不自是,故彰;不自伐,故有功;不自矜,故长。夫唯不争,故天下莫能与之争。古之所谓“曲则全”者,岂虚言哉!诚全而归之。

  • 累计撰写 80 篇文章
  • 累计创建 21 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

Linux服务器使用代理

蜗牛
2023-11-09 / 0 评论 / 0 点赞 / 16 阅读 / 6778 字 / 正在检测是否收录...
  1. 首先你需要一个能使用的代理节点,我这里是xray的vless节点,所以我安装xray-core的内核。

这里提供xray的x86服务器下载地址

第一步获取你节点信息,我这里是用了第三方客户端的JSON信息,直接复制出来的

写入到config.json文件中,下面的xray启动需要这个配置文件

{
	"log": {
		"access": "",
		"error": "",
		"loglevel": "warning"
	},
	"inbounds": [
		{
			"tag": "proxy",
			"port": 1089,
			"listen": "127.0.0.1", //监听本机
			"protocol": "socks", //socks5代理
			"sniffing": {
				"enabled": true,
				"destOverride": ["http", "tls"]
			},
			"settings": {
				"auth": "noauth",
				"network": "tcp,udp"
			}
		},
		{
			"tag": "proxy-docker",
			"port": 1089,
			"listen": "172.17.0.1", //监听容器
			"protocol": "socks", //socks5代理
			"sniffing": {
				"enabled": true,
				"destOverride": ["http", "tls"]
			},
			"settings": {
				"auth": "noauth",
				"network": "tcp,udp"
			}
		},
		{
			"listen": "127.0.0.1", //监听本机
			"port": 8889,
			"protocol": "http", //http代理
			"sniffing": {
				"enabled": true,
				"destOverride": ["http", "tls"]
			},
			"settings": {
				"network": "tcp,udp",
				"auth": "noauth"
			},
			"tag": "http"
		},
		{
			"listen": "172.17.0.1", //监听容器
			"port": 8889,
			"protocol": "http", //http代理
			"sniffing": {
				"enabled": true,
				"destOverride": ["http", "tls"]
			},
			"settings": {
				"network": "tcp,udp",
				"auth": "noauth"
			},
			"tag": "http-docker"
		}
	],
	"outbounds": [ //outbounds部分,就是根据你自己节点情况修改,如果不知道怎么改,就用第三方客户端导出配置文件,替换一下这一部分就可以了。
		{
			"_QV2RAY_USE_GLOBAL_FORWARD_PROXY_": false,
			"mux": {
				"concurrency": 1,
				"enabled": null
			},
			"protocol": "vless",
			"sendThrough": "0.0.0.0",
			"settings": {
				"vnext": [
					{
						"address": "xxx.com",
						"port": 443,
						"users": [
							{
								"encryption": "none",
								"id": "xxx-xxxx"
							}
						]
					}
				]
			},
			"streamSettings": {
				"network": "ws",
				"security": "tls",
				"tlsSettings": {
					"serverName": "xx.gq"
				},
				"wsSettings": {
					"path": "/xx"
				}
			},
			"tag": ""
		}
	],
	"stats": {}
}
  1. 下载最新的xray-core内核
mkdir /root/xray

cd /root/xray

## 下载最新的xray内核

wget https://github.com/XTLS/Xray-core/releases/latest/download/Xray-linux-64.zip

## 解压文件

unzip Xray-linux-64.zip

## 运行,自己可以用systemd或者screen等等后台运行

/root/xray/xray run -c /root/xray/config.json  // 这里的配置文件就是上面的配置文件

如果不提示什么错误,至少表明软件的运行没什么问题

systemd后台运行

#编辑配置文件,输入i,进行编辑,按esc退出编辑,:wq保存退出

vim /etc/systemd/system/xray.service
#添加下面内容

[Unit]

Description=xray Service

After=network.target nss-lookup.target

[Service]

User=root

CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE

AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE

NoNewPrivileges=true

ExecStart=/root/xrayu/xray run -c /root/xray/config.json

Restart=on-failure

RestartPreventExitStatus=23

[Install]

WantedBy=multi-user.target

#以上
#开机自启

systemctl enable xray

#启动

systemctl start xray

#停止

systemctl stop xray

#查看运行状态

systemctl status xray

终端设置代理:

#添加环境变量

vim ~/.bashrc
#或者.zshrc或者/etc/profile
#添加,http和socks5这两个选一个,添加或者删掉#注释即可。

export http_proxy="http://127.0.0.1:8080"

export https_proxy="https://127.0.0.1:8080"

#export http_proxy="socks5://127.0.0.1:1080"

#export https_proxy="socks5://127.0.0.1:1080"
#生效

source ~/.bashrc

#或者

source .zshrc

source /etc/profile

#测试

#不管是http还是socks5都是ping不了的。

curl google.com
0

评论区