[GH-ISSUE #8] nginx 反向代理 #6

Closed
opened 2026-02-26 22:31:09 +03:00 by kerem · 6 comments
Owner

Originally created by @fnhchaiying on GitHub (Dec 23, 2023).
Original GitHub issue: https://github.com/electerm/electerm-web/issues/8

What feature you'd like to see or proposal(期望什么新功能/特性或者建议)

可使用nginx做反向代理,与其他服务共用域名和端口
例如:
已有域名:
http://test.com
添加后的访问方式变为:
http://test.com/electerm

我的nginx配置

map $http_upgrade $connection_upgrade {
        default upgrade;
        '' close;
}
    server {
        listen 80
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_ignore_client_abort on;
        client_max_body_size 10G;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
        location /electerm {
          proxy_pass http://127.0.0.1:5577;
        }
        location /{
          proxy_pass http://127.0.0.1/;
        }
    }
Originally created by @fnhchaiying on GitHub (Dec 23, 2023). Original GitHub issue: https://github.com/electerm/electerm-web/issues/8 ### What feature you'd like to see or proposal(期望什么新功能/特性或者建议) 可使用nginx做反向代理,与其他服务共用域名和端口 例如: 已有域名: http://test.com 添加后的访问方式变为: http://test.com/electerm 我的nginx配置 ``` map $http_upgrade $connection_upgrade { default upgrade; '' close; } server { listen 80 proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $http_host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_ignore_client_abort on; client_max_body_size 10G; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; location /electerm { proxy_pass http://127.0.0.1:5577; } location /{ proxy_pass http://127.0.0.1/; } } ```
kerem closed this issue 2026-02-26 22:31:10 +03:00
Author
Owner

@zxdong262 commented on GitHub (Dec 23, 2023):

可以试试在.env里设置

SERVER=http://test.com/electerm
CDN=http://test.com/electerm

试试

<!-- gh-comment-id:1868193879 --> @zxdong262 commented on GitHub (Dec 23, 2023): 可以试试在.env里设置 ``` SERVER=http://test.com/electerm CDN=http://test.com/electerm ``` 试试
Author
Owner

@fnhchaiying commented on GitHub (Dec 23, 2023):

console中会有以下3个路径报404
GET https://test.com/favicon.ico 404 (Not Found)
GET https://test.com/api 404 (Not Found)
GET https://test.com/icons/ 404 (Not Found)

<!-- gh-comment-id:1868200367 --> @fnhchaiying commented on GitHub (Dec 23, 2023): console中会有以下3个路径报404 GET https://test.com/favicon.ico 404 (Not Found) GET https://test.com/api 404 (Not Found) GET https://test.com/icons/ 404 (Not Found)
Author
Owner

@fnhchaiying commented on GitHub (Dec 23, 2023):

这3个路径可能与其他程序的冲突

<!-- gh-comment-id:1868200457 --> @fnhchaiying commented on GitHub (Dec 23, 2023): 这3个路径可能与其他程序的冲突
Author
Owner

@zxdong262 commented on GitHub (Dec 23, 2023):

对于支持子路径,估计得改很多地方,如果你能控制域名解析,估计设个子域名解析更快

<!-- gh-comment-id:1868208159 --> @zxdong262 commented on GitHub (Dec 23, 2023): 对于支持子路径,估计得改很多地方,如果你能控制域名解析,估计设个子域名解析更快
Author
Owner

@zxdong262 commented on GitHub (Dec 23, 2023):

另外websocket情况也得验证下,总之目前还没有验证对于部署到服务器的支持

<!-- gh-comment-id:1868208334 --> @zxdong262 commented on GitHub (Dec 23, 2023): 另外websocket情况也得验证下,总之目前还没有验证对于部署到服务器的支持
Author
Owner

@fnhchaiying commented on GitHub (Dec 23, 2023):

感谢支持,我使用单独的端口来承载服务吧!

<!-- gh-comment-id:1868228855 --> @fnhchaiying commented on GitHub (Dec 23, 2023): 感谢支持,我使用单独的端口来承载服务吧!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/electerm-web#6
No description provided.