New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] Nginx 無法反代本地的GPT4模型 #4645
Comments
Title: [Bug] Nginx cannot reverse the local GPT4 model Bug DescriptionIn order to solve the CORS problem on my server, I made the following settings: The root at app.mydomain.com is the endpoint that backends to my backend model. I found that the next request after the first one, requesting app.mydomain.com instead of app.mydomain.com/gui, resulted in a 404 error. How can I ensure that the next request is still sent to app.mydomain.com/gui and that nginx proxies it to the correct internal IP and port? Steps to ReproduceI used docker to deploy nextweb: docker compose file is as follows:
Then just set nginx location ^~ /gui { Configure Nginx reverse proxy to the backend: In the Nginx configuration file, set a location block for the root directory of app.mydomain.com and reverse proxy it to the backend (located at http://172.17. 0.9:7077). The following are the relevant Nginx settings: location ^~ / { Expected BehaviorNextweb is functioning normally ScreenshotsDeployment Method
Desktop OSWindows 11 Desktop BrowserChrome Desktop Browser Version125.0.6422.41 Smartphone DeviceNo response Smartphone OSNo response Smartphone BrowserNo response Smartphone Browser VersionNo response Additional LogsNo response |
This comment was marked as spam.
This comment was marked as spam.
On Thu, 9 May, 2024 at 1:59PM, Robert Black @.***>
|
你这里报错静态资源 not found ,原因是由于静态资源打包到根目录了,因此,html中的静态资源地址指向的是根目录,而不是/gui,如果在不修改nextchat 静态资源打包目录的情况下,你需要对静态资源的资源路径也进行rewrite才能解决这个问题 |
The error reported here that static resources are not found is because the static resources are packaged in the root directory. Therefore, the static resource address in HTML points to the root directory, not /gui. If the nextchat static resource packaging directory is not modified, , you need to rewrite the resource path of the static resources to solve this problem. |
Bug Description
在我的伺服器上為了解決CORS的問題,所以我做了如下的設定:
反代 app.mydomain.com/gui 到nextweb (前端GUI), nginx 設定如下:
location ^~ /gui {
proxy_pass http://172.17.0.4:3000/;
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_set_header REMOTE-HOST $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1;
add_header X-Cache $upstream_cache_status;
add_header Strict-Transport-Security "max-age=31536000";
add_header Cache-Control no-cache;
}
在app.mydomain.com 的root 是反代到我的後端模型的endpoint.
location ^~ / {
proxy_pass http://172.17.0.9:7077;
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_set_header REMOTE-HOST $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1;
add_header X-Cache $upstream_cache_status;
add_header Strict-Transport-Security "max-age=31536000";
add_header Cache-Control no-cache;
}
我發現在第一個請求之後的下一個請求,請求 app.mydomain.com 而不是 app.mydomain.com/gui,導致 404 錯誤。我該如何確保下一個請求仍然發送到 app.mydomain.com/gui,並且 nginx 將其代理到正確的內部 IP 和端口?
在部署的時候有寫到base url = app.mydomain.com/gui
Steps to Reproduce
我是用docker 部署nextweb的: docker compose file 如下:
然後就是設定nginx
設定 Nginx 反向代理至前端 GUI: 在的 Nginx 設定檔中,為 app.mydomain.com/gui 設定一個 location 區塊,並將其反向代理至前端 GUI(位於 http://172.17.0.4:3000/)。以下是相關的 Nginx 設定:
location ^~ /gui {
proxy_pass http://172.17.0.4:3000/;
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_set_header REMOTE-HOST $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1;
add_header X-Cache $upstream_cache_status;
add_header Strict-Transport-Security "max-age=31536000";
add_header Cache-Control no-cache;
}
設定 Nginx 反向代理至後端: 在 Nginx 設定檔中,為 app.mydomain.com 的根目錄設定一個 location 區塊,並將其反向代理至後端(位於 http://172.17.0.9:7077)。以下是相關的 Nginx 設定:
location ^~ / {
proxy_pass http://172.17.0.9:7077;
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_set_header REMOTE-HOST $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1;
add_header X-Cache $upstream_cache_status;
add_header Strict-Transport-Security "max-age=31536000";
add_header Cache-Control no-cache;
}
Expected Behavior
Nextweb 正常運作
Screenshots
Deployment Method
Desktop OS
Windows11
Desktop Browser
Chrome
Desktop Browser Version
125.0.6422.41
Smartphone Device
No response
Smartphone OS
No response
Smartphone Browser
No response
Smartphone Browser Version
No response
Additional Logs
No response
The text was updated successfully, but these errors were encountered: