Xray-core icon indicating copy to clipboard operation
Xray-core copied to clipboard

Xray前置后,nginx的转发存在问题

Open yushum opened this issue 5 years ago • 4 comments

Xray fallback到监听10001端口的nginx, nginx已经按照官方示例设置了转发,nextcloud依然出现下图提示。 image

按下示配置

        location = /.well-known/carddav     { return 301 /remote.php/dav/; }
        location = /.well-known/caldav      { return 301 /remote.php/dav/; }

会跳转到https://nextcloud.example.com:10001/remote.php/dav

改成

        location = /.well-known/carddav     { return 301 https://nextcloud.example.com/remote.php/dav/; }
        location = /.well-known/caldav      { return 301 https://nextcloud.example.com/remote.php/dav/; }

才会正常跳转

请问有什么办法可以让nginx按照官方示例正常跳转吗

yushum avatar Jan 31 '21 16:01 yushum

我也是小白,我这边写的是 return 301 https://$server_name/remote.php/dav 可以的

black-head avatar Jan 31 '21 17:01 black-head

我也是小白,我这边写的是 return 301 https://$server_name/remote.php/dav 可以的

这样的确可以👍

但是不知道有没有办法省略前面的https://$server_name

yushum avatar Jan 31 '21 17:01 yushum

server {
    listen 80; #IPv4,http默认监听端口。
    listen [::]:80; #IPv6,http默认监听端口。无IPv6,此项可以删除。
    return 301 https://$host$request_uri; #http自动跳转https,让网站看起来更真实。
}

lxhao61 avatar Jan 31 '21 20:01 lxhao61

这个需要理解本质:Nginx 收到的是 http/h2c 流量而不是 https 流量,return 301 默认当然会补上 http:// 而不是 https://

RPRX avatar Jan 31 '21 23:01 RPRX