V2ray-core: 能否详细介绍一下使用apache转发v2ray的websocket (apache+websocket+tls)

Created on 30 Nov 2017  ·  12Comments  ·  Source: v2ray/v2ray-core

大神们好!小弟自己租了一台vps用于学习国外先进技术,同时用apache自建了webdav用于zotero同步学习资料。近来发现学校开始封锁udp,可能是用迅雷太多闹的,mkcp残废,想用apache+websocket+tls,无奈不是计算机专业,有心无力,真心希望诸神不吝赐教,写个教程,惠泽吾等小白!

Most helpful comment

@mzxwt @PangciPG 我写了个教程,亲测可用:https://dakai.github.io/2017/12/22/v2ray-websocket-tls-apache.html

All 12 comments

不好意思问一下 你有apache的配置文件吗 能分享一下吗 谢谢

抱歉,都是按照教程在nginx上配置的,apache怎么配置不懂。

On Thu, Nov 30, 2017 at 12:50 PM, mzxwt notifications@github.com wrote:

不好意思问一下 你有apache的配置文件吗 能分享一下吗 谢谢


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/v2ray/v2ray-core/issues/747#issuecomment-348081817,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABdF3trh8WjKQb6l0U2Iz8MvfsHABjZVks5s7jQAgaJpZM4Qv41C
.

我也需要一个apache的,找到的都是nginx的,虽然nginx用的挺好的

@mzxwt @PangciPG 我写了个教程,亲测可用:https://dakai.github.io/2017/12/22/v2ray-websocket-tls-apache.html

@Dakai 你好,我跟着你的教程顺利完成了v2ray的转发,不过原来网站却无法用https连接访问了。
我原来的配置是

<VirtualHost *:443>
            ServerAdmin  webmaster@localhost
            DocumentRoot /var/www/hexo
            ErrorLog ${APACHE_LOG_DIR}/error.log
            CustomLog ${APACHE_LOG_DIR}/access.log combined
            SSLEngine on
            SSLCertificateFile      /etc/v2ray/v2ray.crt;
            SSLCertificateKeyFile  /etc/v2ray/v2ray.key;
</VirtualHost>

请问有什么办法可以同时用https访问网站并转发v2ray流量到3579端口吗?谢谢

@lostanother 你好,教程可能有些误导,你是否把主域名用来转发v2ray流量了?我是用的一个子域名来转发的,主域名不受影响,具体来说:
etc/apache/sites-available或/etc/httpd/sites-available目录下有两个conf文件,
一个是主域名yourdomain.com.conf,另一个是用来转发V2ray流量的subdomain.yourdomain.com.conf,V2ray配置在后者子域名文件里面,配置如下供参考:

    <VirtualHost *:443>

    ServerName subdomain.yourdomain.com
    ServerAlias subdomain.yourdomain.com
    ##SSL Engine Switch:
    #Enable/Disable SSL for this virtual host.
    SSLEngine On

    RewriteEngine On
    RewriteCond %{HTTP:Upgrade} =websocket [NC]
    RewriteRule /(.*)           ws://localhost:3579/$1 [P,L]
    RewriteCond %{HTTP:Upgrade} !=websocket [NC]
    RewriteRule /(.*)           http://localhost:3579/$1 [P,L]

    ##Proxy to port 3579
    SSLProxyEngine On
    Proxypass /ray http://127.0.0.1:3579
    ProxyPassReverse /ray http://127.0.0.1:3579
    SSLCertificateFile /etc/v2ray/v2ray.crt
    SSLCertificateKeyFile /etc/v2ray/v2ray.key

    </VirtualHost>

设置好后要在DNS管理里把子域名加进去。

@lostanother @Dakai

<LocationMatch "/{ws_path}}/">
    ProxyPass ws://127.0.0.1:{port}/{ws_path}/ upgrade=WebSocket
    ProxyAddHeaders Off
    ProxyPreserveHost On
    RequestHeader set Host %{HTTP_HOST}s
    RequestHeader set X-Forwarded-For %{REMOTE_ADDR}s
</LocationMatch>

加到<VirtualHost></VirtualHost>之间

需要的mods:

  • mod_ssl
  • mod_proxy
  • mod_proxy_wstunnel
  • 以上三个mods所依赖的mods

@mzxwt @PangciPG 我写了个教程,亲测可用:https://dakai.github.io/2017/12/22/v2ray-websocket-tls-apache.html

官方教程不行,你的可行NB

@Dakai
Apache配置中的
RewriteCond %{HTTP:Upgrade} !=websocket [NC]
RewriteRule /(.*) http://localhost:3579/$1 [P,L]
中第二行,这块是非websocket请求,应该换成本地域名,而不是继续转3579端口吧?

@Dakai
Apache 配置中的
RewriteCond %{HTTP:Upgrade} !=websocket [NC]
RewriteRule /(.*) http://localhost:3579/$1 [P,L]
中第二行,这块是非 websocket 请求,应该换成本地域名,而不是继续转 3579 端口吧?

好像是的,你可以试试去掉第二段看看是否还能用?
我已经用回nginx了,没法试验了

Was this page helpful?
0 / 5 - 0 ratings

Related issues

limaofu picture limaofu  ·  3Comments

ghost picture ghost  ·  4Comments

gzzchh picture gzzchh  ·  3Comments

supersonic600 picture supersonic600  ·  3Comments

FTAndy picture FTAndy  ·  4Comments