当前位置: 首页 > news >正文

阿里云 ECS 怎么用 nginx 部署80端口多个网站

怎么用一个域名情况下根据不同地址怎么部署多个网站

首先安装 nginx

Alibaba Cloud Linux 3 生成 nginx-CSDN博客

其次删除 /etc/nginx/nginx.conf 下的 80 端口 serve 配置

然后在 /etc/nginx/nginx.conf/conf.d 目录下创建 default.conf

server {listen       80;server_name  localhost;access_log  /var/log/nginx/host.access.log  main;location / {proxy_pass http://127.27.25.192:5001/;}location /commit {proxy_pass http://127.27.25.192:5001/;}location /github {proxy_pass http://127.27.25.192:5002/;}location /tools {proxy_pass http://127.27.25.192:5003/;}error_page   500 502 503 504  /50x.html;location = /50x.html {root   /usr/share/nginx/html;}
}

我的域名是 huyunan.xyz ,需要先备案 ,然后解析到阿里云服务器的外网IP地址,下面的127.27.25.192 是我的内网IP地址。

访问 http://huyunan.xyz 后默认路径是 / 跳转到 http://127.27.25.192:5001/

访问 http://huyunan.xyz/commit  也是跳转到 http://127.27.25.192:5001/ 所以 /commit 这个网站是默认的。

然后其它路径比如 http://huyunan.xyz/tools  跳转到 http://127.27.25.192:5003/ 这个网站

现在还需要阿里云服务器允许这5001 这几个端口入站出站

入方向和出方向都要添加

然后配置具体网站静态文件路径,添加 github-commit.conf 文件

server {listen       5001;server_name  localhost;#access_log  /var/log/nginx/host.access.log  main;location / {root   /app/commit/dist;try_files $uri $uri/ = 404;index  index.html index.htm;}error_page  404              /404.html;
}

自备网站静态文件,注意网站打开地址必须是 http://localhost:8080/commit/ 这种带 /commit 路径的与上面配置的 /commit 名称对上,不然不好使。

编译后生成的 dist 文件夹放到 /app/commit 目录下。

重启 nginx 配置

systemctl reload nginx

如果你的网站备案成功可以直接用域名访问,不然也可以用公网IP访问

http://huyunan.xyz/commit/

http://www.lryc.cn/news/615225.html

相关文章:

  • 组件通信的方式
  • Docker容器部署Tomcat线上商城
  • Leetcode——556. 下一个更大元素 III
  • 八、《DaaS(设备即服务):企业轻资产化新路径》--从97.4%首期投入削减到AI算力高效迭代的范式革命
  • Spring 框架中提供Aware接口,实现感知容器对象
  • spring.config.import 不存在
  • “高大上“的SpringCloud?(微服务体系入门)
  • ELK常见的问题
  • 智能机票助手-接入Ollama本地模型-Spring-AI-Alibaba
  • 在ubuntu服务器下安装cuda和cudnn(笔记)
  • 揭秘MyBatis核心类MappedStatement
  • 多模态RAG赛题实战--Datawhale AI夏令营
  • 如何分析需求的可行性
  • 生产环境某业务服务JVM调优总结
  • 避免在微信小程序中频繁使用setData方法
  • 扩散LLM推理新范式:打破生成长度限制,实现动态自适应调节
  • 机器学习——09 聚类算法
  • BGP 协议笔记
  • 使用qemu运行与GDB调试内核
  • 微软推出革命性AI安全工具Project IRE,重塑网络安全防御新范式
  • 用天气预测理解分类算法-从出门看天气到逻辑回归
  • Kubernetes(K8s)不同行业的典型应用场景及价值分析 原创
  • windows、linux应急响应入侵排查
  • Qdrant Filtering:must / should / must_not 全解析(含 Python 实操)
  • 【2025】Datawhale AI夏令营-多模态RAG-Task1、Task2笔记-任务理解与Baseline代码解读
  • 金融通用智能体(Financial General Agent, FGA)的端到端解决方案
  • 机器翻译中的语言学基础详解(包括包括语法、句法和语义学等)
  • C语言:构造类型
  • TDengine IDMP 产品基本概念
  • 使用 Visual Studio 2022 编译 PortAudio 项目