Coder Social home page Coder Social logo

用nginx反向代理问题 about chatgpt-web HOT 12 CLOSED

opsxff avatar opsxff commented on May 19, 2024
用nginx反向代理问题

from chatgpt-web.

Comments (12)

zhujunsan avatar zhujunsan commented on May 19, 2024

是否能贴例如详细的Nginx配置上来呢?

from chatgpt-web.

opsxff avatar opsxff commented on May 19, 2024

是否能贴例如详细的Nginx配置上来呢?

    location /chatgpt-web {
        proxy_pass http://172.30.0.7:3002/;
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_buffering off;
    }

就这样的,172.30.0.7是chatgpt-web容器

from chatgpt-web.

zhujunsan avatar zhujunsan commented on May 19, 2024

第一行试试
location /chatgpt-web/ {

from chatgpt-web.

opsxff avatar opsxff commented on May 19, 2024

第一行试试 location /chatgpt-web/ {

这个斜杠我加了,不过它这个还没有到反向代理那,它让浏览器请求访问的https://xxx:443/assets/...没有进入到chatgpt-web这个location。我问chatgpt它说是代码返回的url有问题

from chatgpt-web.

zhujunsan avatar zhujunsan commented on May 19, 2024

第二行3002后面的斜杠去掉呢?

from chatgpt-web.

zhujunsan avatar zhujunsan commented on May 19, 2024

查下Nginx反向代理的写法就好了

from chatgpt-web.

opsxff avatar opsxff commented on May 19, 2024

还有没有其他办法。这个第一个请求都是成功的,所以不是反向代理路径的问题(之前我就都试过),是返给浏览器发起的请求没加我的location
image

from chatgpt-web.

hicaoc avatar hicaoc commented on May 19, 2024

这种情况,一般要rewrite下请求的路径,或者后端web要支持部署到chat-web目录,否则后端是将自己的资源路径直接返回给nginx,然后到用户

from chatgpt-web.

zhujunsan avatar zhujunsan commented on May 19, 2024

嗯...express 是基于根目录绑定路径的...

如果你要部署的话,需要修改 service\src\index.ts 的 L703-704,把 '' 和 '/api' 改成比如 '/chatgpt-web' 和 '/chatgpt-web/api',然后打包,部署

from chatgpt-web.

opsxff avatar opsxff commented on May 19, 2024

感谢,我研究下

from chatgpt-web.

xiechenghua01 avatar xiechenghua01 commented on May 19, 2024

还有其他办法。这个第一个请求都是成功的,所以不是反向代理路径的问题(之前我都试过),是返回给浏览器发起的请求没有加我的位置 图像

静态文件也需要反向代理,这样可以解决css文件和js文件访问404的问题。

image

from chatgpt-web.

opsxff avatar opsxff commented on May 19, 2024

谢谢你,我后头还是选择加了条解析单独代理,懒得弄了

from chatgpt-web.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.