xizeyoupan / Meting-API

🐳 Meting API 的容器化与部署
https://meting-dd.2333332.xyz
208 stars 207 forks source link

feat: support configure meting.url into env #1

Closed Naccl closed 1 year ago

Naccl commented 1 year ago

使用当前镜像部署到自己的服务器,通过 nginx 反代

server {
    location /meting/ {
        proxy_pass http://127.0.0.1:3000/;
    }
}

会导致下图 url 错误

image

稍微修改了一下,添加个可选环境变量

docker run -d --name meting -p 3000:3000 -e METING_URL="https://api.example.com/meting"
vercel[bot] commented 1 year ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
meting-api ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Jan 28, 2023 at 4:40PM (UTC)
xizeyoupan commented 1 year ago

您好,您试过添加X-Forwarded-Host标头吗?比如下面:

server {
    location /meting/ {
        proxy_pass http://127.0.0.1:3000/;
        proxy_set_header X-Forwarded-Host $host:$server_port/meting;
    }
}

在我这里好像有用。

xizeyoupan commented 1 year ago

另外近期我可能会重写一下后端。

Naccl commented 1 year ago

试过的,nginx 改 origin 会和 CORS 冲突,不过我没有细看后端的逻辑,不确定是不是酱紫。

另外近期我可能会重写一下后端。

OK的,这个PR随意就好,我这边配了环境变量能跑了👀

Naccl commented 1 year ago

好吧我又试了下,之前把 X-Forwarded-Host 写成 origin 了,这样写可以了,感谢!

server {
    location /meting/ {
        proxy_pass http://127.0.0.1:3000/;
        proxy_set_header X-Forwarded-Host $host/meting;
        proxy_set_header X-Forwarded-Proto https;
    }
}