duanfeigui6655 2017-07-15 07:49
浏览 116
已采纳

如何使用golang微服务? [关闭]

My company use Go to build some HTTP API services. We want these services share one HTTP port.

So the solution right now is we create a project named router, and router import some modules, every request pass through router to their own modules.
But the question is that if one of these modules process crashed, the router just crash.

Is there any solutions?

Require:

  1. One http port.
  2. Every service is independent.

I know go-kit and go micro, also I have tried, but still not too understand.

  • 写回答

3条回答 默认 最新

  • dongmin4990 2017-07-15 08:15
    关注

    Go-kit and go-micro are for writing microservices, it won't solve your problem.

    You should use a reverse proxy in front of your applications, for instance Nginx: https://www.nginx.com/resources/admin-guide/reverse-proxy/

    Here is an example of a nginx configuration file that does what you want:

    server {
       listen 80 default_server;
       server_name your-domain;
    
       location /app1 {
          proxy_set_header X-Real-IP $remote_addr;
          proxy_pass http://localhost:3000;
       }
    
       location /app2 {
          proxy_set_header X-Real-IP $remote_addr;
          proxy_pass http://localhost:4000;
       }
    }
    

    This way, you still deploy your applications on different ports, but they will only be exposed through the port 80.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c