[GH-ISSUE #3025] [Feature Request] 是否可以将http和https绑定到相同端口? #2417

Closed
opened 2026-05-05 13:33:14 -06:00 by gitea-mirror · 4 comments
Owner

Originally created by @chingxuds on GitHub (Jul 20, 2022).
Original GitHub issue: https://github.com/fatedier/frp/issues/3025

Describe the feature request

如题,是否可以将http和https绑定到相同端口,依据域名进行服务区分。

Describe alternatives you've considered

No response

Affected area

  • Docs
  • Installation
  • Performance and Scalability
  • Security
  • User Experience
  • Test and Release
  • Developer Infrastructure
  • Client Plugin
  • Server Plugin
  • Extensions
  • Others
Originally created by @chingxuds on GitHub (Jul 20, 2022). Original GitHub issue: https://github.com/fatedier/frp/issues/3025 ### Describe the feature request 如题,是否可以将http和https绑定到相同端口,依据域名进行服务区分。 ### Describe alternatives you've considered _No response_ ### Affected area - [ ] Docs - [ ] Installation - [ ] Performance and Scalability - [ ] Security - [ ] User Experience - [ ] Test and Release - [ ] Developer Infrastructure - [ ] Client Plugin - [X] Server Plugin - [ ] Extensions - [ ] Others
gitea-mirror 2026-05-05 13:33:14 -06:00
Author
Owner

@Becods commented on GitHub (Jul 20, 2022):

莫名其妙

请补充一下使用场景

前端http默认80 https默认443 这个不用管

非标的话还要绑域名,是不是有点多此一举

tcp映射后端nginx把http和https配置写一块就行了

<!-- gh-comment-id:1190029293 --> @Becods commented on GitHub (Jul 20, 2022): 莫名其妙 请补充一下使用场景 前端http默认80 https默认443 这个不用管 非标的话还要绑域名,是不是有点多此一举 tcp映射后端nginx把http和https配置写一块就行了
Author
Owner

@chingxuds commented on GitHub (Jul 20, 2022):

莫名其妙

请补充一下使用场景

前端http默认80 https默认443 这个不用管

非标的话还要绑域名,是不是有点多此一举

tcp映射后端nginx把http和https配置写一块就行了

是这样的,我在云主机上搭建了frps,通过nginx作泛域名反向代理。
现在http和https因为是两个不同的端口,需要反代两次,而泛域名无法知道哪个服务需要使用http,哪个需要使用https,就只能先尝试https,失败后再试http。
如果是同一个端口,则只需要反代一次就足够了。

<!-- gh-comment-id:1190042989 --> @chingxuds commented on GitHub (Jul 20, 2022): > 莫名其妙 > > 请补充一下使用场景 > > 前端http默认80 https默认443 这个不用管 > > 非标的话还要绑域名,是不是有点多此一举 > > tcp映射后端nginx把http和https配置写一块就行了 是这样的,我在云主机上搭建了frps,通过nginx作泛域名反向代理。 现在http和https因为是两个不同的端口,需要反代两次,而泛域名无法知道哪个服务需要使用http,哪个需要使用https,就只能先尝试https,失败后再试http。 如果是同一个端口,则只需要反代一次就足够了。
Author
Owner

@fuyoo commented on GitHub (Jul 28, 2022):

莫名其妙
请补充一下使用场景
前端http默认80 https默认443 这个不用管
非标的话还要绑域名,是不是有点多此一举
tcp映射后端nginx把http和https配置写一块就行了

是这样的,我在云主机上搭建了frps,通过nginx作泛域名反向代理。 现在http和https因为是两个不同的端口,需要反代两次,而泛域名无法知道哪个服务需要使用http,哪个需要使用https,就只能先尝试https,失败后再试http。 如果是同一个端口,则只需要反代一次就足够了。

你那个https在nginx校验就行了啊。为什么要在frps上走证书?例如:nignx 配置

server
{
    listen 80;
		listen 443 ssl http2;
    server_name ~^(?<subdomain>.+).demo.com$;
 ssl_certificate    /www/cert/fullchain.pem;
    ssl_certificate_key    /www/cert/privkey.pem;
    ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
    ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 10m;
    add_header Strict-Transport-Security "max-age=31536000";
    error_page 497  https://$host$request_uri;
 location ~/ {
      proxy_set_header Host $host;
      proxy_pass http://frps的ip+端口;
    }
}

这样不需要frps的443端口

<!-- gh-comment-id:1197550941 --> @fuyoo commented on GitHub (Jul 28, 2022): > > 莫名其妙 > > 请补充一下使用场景 > > 前端http默认80 https默认443 这个不用管 > > 非标的话还要绑域名,是不是有点多此一举 > > tcp映射后端nginx把http和https配置写一块就行了 > > 是这样的,我在云主机上搭建了frps,通过nginx作泛域名反向代理。 现在http和https因为是两个不同的端口,需要反代两次,而泛域名无法知道哪个服务需要使用http,哪个需要使用https,就只能先尝试https,失败后再试http。 如果是同一个端口,则只需要反代一次就足够了。 你那个https在nginx校验就行了啊。为什么要在frps上走证书?例如:nignx 配置 ```shell server { listen 80; listen 443 ssl http2; server_name ~^(?<subdomain>.+).demo.com$; ssl_certificate /www/cert/fullchain.pem; ssl_certificate_key /www/cert/privkey.pem; ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3; ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5; ssl_prefer_server_ciphers on; ssl_session_cache shared:SSL:10m; ssl_session_timeout 10m; add_header Strict-Transport-Security "max-age=31536000"; error_page 497 https://$host$request_uri; location ~/ { proxy_set_header Host $host; proxy_pass http://frps的ip+端口; } } ``` 这样不需要frps的443端口
Author
Owner

@github-actions[bot] commented on GitHub (Aug 28, 2022):

Issues go stale after 30d of inactivity. Stale issues rot after an additional 7d of inactivity and eventually close.

<!-- gh-comment-id:1229346860 --> @github-actions[bot] commented on GitHub (Aug 28, 2022): Issues go stale after 30d of inactivity. Stale issues rot after an additional 7d of inactivity and eventually close.
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: github-starred/frp#2417
No description provided.