接外包,有相关需求的可以联系我:Telegram | Email

V2Ray + TLS + WS + Nginx + Cloudflare + 宝塔

该文章创建(更新)于01/10/2022,请注意文章的时效性!

最近升级了一下服务器端的版本后发现突然不能用了,感觉就很奇怪。刚开始以为又被墙了就尝试以前的方法V2ray+Apache+Cdn+Tls,多次尝试感觉有点问题 就尝试找了一个新的方法。【虽然最后发现和配置文件有关,配置文件中的alterId 在2020-01-01后只能设置成0,和上面AED有啥关系。具体也不太懂,懂的可以留言说明。】

前提

  • 一个域名,有免费的tk,ml域名可以申请
  • 服务器(废话)
  • CLoudFlare(代理)

步骤

配置文件

注意其中的配置信息按需修改,主要是域名、端口以及id。

{
    "log": {
        "access": "",
        "error": "",
        "loglevel": "info"
    },
    "inbounds": [
        {
            "port": 22000,
            "protocol": "vless",
            "settings": {
                "udp": false,
                "clients": [
                    {
                        "id": "xxx",
                        "alterId": 0,
                        "email": "[email protected]",
                        "flow": ""
                    }
                ],
                "decryption": "none"
            },
            "streamSettings": {
                "network": "ws",
                "wsSettings": {
                    "path": "/ws",
                    "headers": {
                        "Host": "xxx.yyyy.ml"
                    }
                }
            }
        },
        {
            "port": 22000,
            "protocol": "vmess",
            "settings": {
                "udp": false,
                "clients": [
                    {
                        "id": "xxx",
                        "alterId": 0,
                        "email": "[email protected]"
                    }
                ],
                "allowTransparent": false
            },
            "streamSettings": {
                "network": "ws",
                "wsSettings": {
                    "path": "/ws",
                    "headers": {
                        "Host": "xxx.yyyy.ml"
                    }
                }
            }
        }
    ],
    "outbounds": [
        {
            "protocol": "freedom",
            "settings": {}
        },
        {
            "protocol": "blackhole",
            "settings": {},
            "tag": "blocked"
        }
    ],
    "routing": {
        "rules": [
            {
                "type": "field",
                "ip": [
                    "geoip:private"
                ],
                "outboundTag": "blocked"
            }
        ]
    }
}

docker部署v2ray

也可以用其它的,不一定用docker。/etc/v2ray-fly/是配置文件的路径,按需修改。

docker run -d --name v2ray-fly -v /etc/v2ray-fly/:/etc/v2ray/ -p 22000:22000 v2fly/v2fly-core

网站配置

前提

域名获取、配置、ssl配置以及宝塔安装等等。

网站nginx配置

location / {
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
}

location /ws {
    proxy_redirect off;
    proxy_pass http://127.0.0.1:22000;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
  • 可能nginx因配置问题有一些相关报错,主要是全局配置性的东西。这里我贴出自己的nginx配置,仅供参考。
user  www www;
worker_processes auto;
error_log  /www/wwwlogs/nginx_error.log  crit;
pid        /www/server/nginx/logs/nginx.pid;
worker_rlimit_nofile 51200;

events
    {
        use epoll;
        worker_connections 128;
        multi_accept on;
    }

http
    {

        map $http_upgrade $connection_upgrade {
            default upgrade;
            ''      close;
        }

        include       mime.types;
        #include luawaf.conf;

        include proxy.conf;

        proxy_headers_hash_max_size 51200;
        proxy_headers_hash_bucket_size 6400;

        #default upgrade;

        default_type  application/octet-stream;

        server_names_hash_bucket_size 512;
        client_header_buffer_size 32k;
        large_client_header_buffers 4 32k;
        client_max_body_size 50m;

        sendfile   on;
        tcp_nopush on;

        keepalive_timeout 60;

        tcp_nodelay on;

        fastcgi_connect_timeout 300;
        fastcgi_send_timeout 300;
        fastcgi_read_timeout 300;
        fastcgi_buffer_size 64k;
        fastcgi_buffers 4 64k;
        fastcgi_busy_buffers_size 128k;
        fastcgi_temp_file_write_size 256k;
        fastcgi_intercept_errors on;

        gzip on;
        gzip_min_length 1k;
        gzip_buffers     4 16k;
        gzip_http_version 1.1;
        gzip_comp_level 8;
        gzip_types     text/plain application/javascript application/x-javascript text/javascript text/css application/xml;
        gzip_vary on;
        gzip_proxied   expired no-cache no-store private auth;
        gzip_disable   "MSIE [1-6]\.";

        limit_conn_zone $binary_remote_addr zone=perip:10m;
        limit_conn_zone $server_name zone=perserver:10m;

        server_tokens off;
        access_log off;

    server{
        listen 888;
        server_name phpmyadmin;
        index index.html index.htm index.php;
        root  /www/server/phpmyadmin;
            location ~ /tmp/ {
                return 403;
            }

        #error_page   404   /404.html;
        include enable-php.conf;

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        location ~ /\.
        {
            deny all;
        }

        access_log  /www/wwwlogs/access.log;
    }
include /www/server/panel/vhost/nginx/*.conf;
}

CDN 开启

  • 点亮小黄云

  • 加密模式设为完全(FULL)

客户端配置



👇 Share | 分享 👇


要不赞赏一下?

微信
支付宝
PayPal
Bitcoin

版权声明 | Copyright

除非特别说明,本博客所有作品均采用知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议进行许可。转载请注明转自-
https://www.emperinter.info/2022/01/10/v2ray-tls-ws-nginx-cloudflare-bt/


要不聊聊?

我相信你准备留下的内容是经过思考的!【勾选防爬虫,未勾选无法留言】

*

*



微信公众号

👉 NewsLetter ❤️ 邮箱订阅 👈

优惠码


阿里云国际版20美元
Vultr10美元
搬瓦工 | Bandwagon应该有折扣吧?
域名 | namesiloemperinter(1美元)