dongyangben6144 2017-04-01 21:17
浏览 556
已采纳

使用Beego将服务器API转发到另一个端口

I have two web apps running in the same virtual machine. One is Beego listening to port 443, and another is Centrifugo messaging server at port 8000.

If a user is not allowed to connect port 8000 due to his ISP, is it possible that I forward https://my.domain/chat_api (intercepted by Beego at port 443) to https://my.domain:8000/chat_api (served by Centrifugo at port 8000), so that my chat client connects port 443 just like connecting port 8000? If yes, how do I implement under Beego's structure?

  • 写回答

1条回答 默认 最新

  • dourao1968 2017-04-04 07:26
    关注

    You dont need to implement this in Beego.

    Just set up a reverse proxy: (here is an example how to set up a reverse proxy with nginx)

    server {
       listen 443;
       server_name example.com;
    
       location /chat_api {
          proxy_set_header   X-Forwarded-For $remote_addr;
          proxy_set_header   Host $http_host;
          proxy_pass         "http://127.0.0.1:8000";
       }
       location /beego {
          proxy_set_header   X-Forwarded-For $remote_addr;
          proxy_set_header   Host $http_host;
          proxy_pass         "http://127.0.0.1:8080";
       }
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题