将子域重定向到端口 [nginx/flask]

编程入门 行业动态 更新时间:2024-10-22 21:24:01
本文介绍了将子域重定向到端口 [nginx/flask]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我知道这是一个常见问题,并且有相同的答案,但我问这个问题的原因是因为我不知道如何解决这个问题.根据我决定的方式,我可以选择更改的解决方案.总之,

I know that this is a common question, and there are answers for the same, but the reason I ask this question is because I do not know how to approach the solution. Depending on the way I decide to do it, the solution I can pick changes. Anyways,

我有一个 AWS EC2 实例.我的 DNS 由 Route53 处理,我拥有 example.目前,在我的实例上,有两个服务正在运行:

I have an AWS EC2 instance. My DNS is handled by Route53 and I own example. Currently, on my instance, there are two services running:

example:80 [nginx/php/wordpress] example:8142 [flask]

我想做的是,让 app.example 指向 example:8142.我该怎么做呢?我很确定我必须将 app.example 指向与 example 相同的 IP,因为它是为它提供服务的同一个框.而且,nginx 将是第一个在端口 80 处理这些请求的.有没有办法让 nginx 将所有请求转发到 localhost:8142?

What I want to do is, make app.example point to example:8142. How exactly do I go about doing this? I am pretty sure that I will have to point app.example to the same IP as example, since it is the same box that will be serving it. And, nginx will be the first one to handle these requests at port 80. Is there a way with which I can make nginx forward all requests to localhost:8142?

有没有更好的方法可以解决这个问题?

Is there a better way that I can solve this problem?

推荐答案

你可以为 app.example 添加一个虚拟主机,监听 80 端口,然后代理将所有请求传递给flask:

You could add a virtual host for app.example that listens on port 80 then proxy pass all requests to flask:

server { listen 80; server_name app.example; location / { proxy_pass localhost:8142; } }

更多推荐

将子域重定向到端口 [nginx/flask]

本文发布于:2023-10-31 16:25:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1546629.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:端口   重定向   将子域   nginx   flask

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!