使用NGINX将端口80转发到8080

编程入门 行业动态 更新时间:2024-10-25 02:20:45
本文介绍了使用NGINX将端口80转发到8080的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在我的debian服务器上使用LEMP堆栈和Node JS. Nginx在端口80和8080的Node JS上工作.我为nodejs应用创建了新的子域:cdn.domain.目前,我只能访问cdn.domain:8080/之类的Node JS应用程序.我想做的是配置Nginx,以便当我进入cdn.domain时,我可以使应用程序在端口80上工作.我认为可以使用nginx上游来完成.但是我不知道怎么做.

I'm using LEMP stack and Node JS on my debian server. Nginx works on port 80 and Node JS on 8080. I created new subdomain: cdn.domain for nodejs app. Currently I can access to Node JS application only like cdn.domain:8080/. What I want to do is to configure Nginx so that, when I enter to cdn.domain I can get app working on port 80. I think it can be done using nginx upstream. But I can't figure out how.

推荐答案

像这样简单,

确保将example更改为您的域(或IP),并将8080更改为您的Node.js应用程序端口:

make sure to change example to your domain (or IP), and 8080 to your Node.js application port:

server { listen 80; server_name example; location / { proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $http_host; proxy_pass "127.0.0.1:8080"; } }

来源: eladnava/binding-nodejs-port -80-using-nginx/

更多推荐

使用NGINX将端口80转发到8080

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

发布评论

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

>www.elefans.com

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