2020年5月11日星期一

基于apache的v2ray网络代理服务设置

blog.paotung.org
/var/www
47e37f31-2f77-4f07-86eb-21ac236704e1
/ray

前置
  • sudo -i
root权限
  • sudo apt update
更新安装源
第一篇:V2Ray安装&配置
  • sudo bash <(curl -L -s https://install.direct/go.sh)
安装V2Ray程序https://www.v2ray.com/chapter_00/install.html#linuxscript
  • sudo vi /etc/v2ray/config.json
替换如下内容到config.json文件
{
  "inbounds": [
    {
      "port": 3128,
      "listen":"127.0.0.1",
      "protocol": "vmess",
      "settings": {
        "clients": [
          {
            "id": "47e37f31-2f77-4f07-86eb-21ac236704e1",
            "alterId": 64
          }
        ]
      },
      "streamSettings": {
        "network": "ws",
        "wsSettings": {
        "path": "/ray"
        }
      }
    }
  ],
  "outbounds": [
    {
      "protocol": "freedom",
      "settings": {}
    }
  ]
}
第二篇:Certbot安装&配置
  • sudo apt install certbot python-certbot-apache
安装证书程序
  • sudo certbot certonly --apache -d blog.paotung.org
配置当前域名证书
  • sudo certbot renew --dry-run
配置证书自动续订
第三篇:Apache安装&配置
  • sudo apt install apache2 php libapache2-mod-php
安装Apache  http://httpd.apache.org/docs/current/install.html
  • sudo a2enmod proxy
代理使能  参阅https://httpd.apache.org/docs/2.4/zh-cn/mod/mod_proxy.html
  • sudo a2enmod proxy_wstunnel
WS代理使能  参阅https://httpd.apache.org/docs/2.4/zh-cn/mod/mod_proxy_wstunnel.html
  • sudo mkdir -p /var/www/blog.paotung.org
建立虚拟WEB服务器目录
  • sudo chmod -R 777 /var/www/blog.paotung.org
更改目录权限
  • sudo vi /etc/apache2/sites-available/blog.paotung.org.conf
替换如下内容到blog.paotung.org.conf文件
<VirtualHost *:80>
    ServerAdmin admin@localhost
    ServerName blog.paotung.org
    DocumentRoot /var/www/blog.paotung.org
RewriteEngine on
RewriteCond %{SERVER_NAME} =blog.paotung.org
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
<VirtualHost *:443>
    ServerAdmin admin@localhost
    ServerName blog.paotung.org
    DocumentRoot /var/www/blog.paotung.org
SSLProxyEngine On
ProxyPass "/ray" "ws://localhost:3128/ray"
ProxyPassReverse "/ray" "ws://localhost:3128/ray"
SSLEngine On
SSLCertificateFile /etc/letsencrypt/live/blog.paotung.org/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/blog.paotung.org/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
  • sudo a2ensite blog.paotung.org.conf
编译使能
第四篇:Crontab安装&配置
  • sudo apt install cron
安装Crontab程序源
  • sudo systemctl restart cron
设置Crontab随机启动
  • sudo crontab -e
添加如下红色字体内容(首次会选择编辑器),每月一日零点重启vps
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h  dom mon dow   command
0 0 1 * * /sbin/reboot
第六篇:重启
  • sudo reboot
重启

88

 88f