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

Nginx中部署多个前端项目

1,准备前端项目

tlias系统的前端资源

外卖项目的前端资源

2,nginx里面的html文件夹中新建,tlias和sky两个文件夹。

切记这是在nginx/html下创建的

mkdir sky
mkdir tlias

把tlias和sky的资源都放到对应的文件夹中

3,编辑配置nginx.conf文件

第一个server监听88端口,

第二个server监听 81端口


#user  nobody;
worker_processes  1;#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;#pid        logs/nginx.pid;events {worker_connections  1024;
}http {include       mime.types;default_type  application/octet-stream;#log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '#                  '$status $body_bytes_sent "$http_referer" '#                  '"$http_user_agent" "$http_x_forwarded_for"';#access_log  logs/access.log  main;sendfile        on;#tcp_nopush     on;#keepalive_timeout  0;keepalive_timeout  65;#gzip  on;map $http_upgrade $connection_upgrade{default upgrade;'' close;}server {listen       88;server_name  localhost;#charset koi8-r;#access_log  logs/host.access.log  main;location / {root   html/sky;index  index.html index.htm;}error_page   500 502 503 504  /50x.html;location = /50x.html {root   html;}# ▒▒▒▒▒▒▒,▒▒▒▒▒▒▒˷▒▒͵▒▒▒▒▒location /api/ {proxy_pass   http://localhost:8080/admin/;}# ▒▒▒▒▒▒▒,▒▒▒▒▒û▒▒˷▒▒͵▒▒▒▒▒location /user/ {proxy_pass   http://localhost:8080/user/;}# WebSocketlocation /ws/ {proxy_pass   http://localhost:8080/ws/;proxy_http_version 1.1;proxy_read_timeout 3600s;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection "$connection_upgrade";}}server {listen       81;server_name  localhost;client_max_body_size 10m;location / {root   html/tlias;index  index.html index.htm;}location ^~ /api/ {rewrite ^/api/(.*)$ /$1 break;proxy_pass http://localhost:8081;}}}

4,重启nginx

注意!!! 我下面列举的 启动,停止,重启。都是在 Nginx的sbin目录下执行的

一般我们改了 conf文件之后就会重启下nginx

./nginx -s reload

补充下nginx的常用命令

启动命令
./nginx

查看下进程是否起来了

关闭命令
./nginx -s stop

再看看是否还有nginx进程在运行

5,看效果:

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

相关文章:

  • 1688寻源通:赋能跨境贸易的高效业务平台
  • JVM深入学习(一)
  • Qt Creator 15.0.0如何更换主题和字体
  • “大模型横扫千军”背后的大数据挖掘--浅谈MapReduce
  • shallowRef和shallowReactive的用法以及使用场景和ref和reactive的区别
  • maven、npm、pip、yum官方镜像修改文档
  • HTML5+SVG+CSS3实现雪中点亮的圣诞树动画效果源码
  • HTML-新浪新闻-实现标题-样式1
  • Linux-day10
  • 【Unity3D】《跳舞的线》游戏的方块单方向拉伸实现案例
  • AI智能日志分析系统
  • 试用ChatGPT开发一个大语言模型聊天App
  • Unity Epplus读取excel表并存入So文件举例
  • 连接 OpenAI 模型:基础操作
  • [ Spring ] Spring Cloud Alibaba Message Stream Binder for RocketMQ 2025
  • ubuntu 更新24LTS中断导致“系统出错且无法恢复,请联系系统管理员”
  • 力扣-链表-203 移除链表元素
  • Unity中关于实现 管道水流+瀑布流动+大肠蠕动效果笔记
  • 宏_wps_宏修改word中所有excel表格的格式_设置字体对齐格式_删除空行等
  • Linux——网络(udp)
  • Oracle-Java JDBC 连接超时之后的认知纠正
  • 自定义数据集使用框架的线性回归方法对其进行拟合
  • 15天基础内容-5
  • 82,【6】BUUCTF WEB .[CISCN2019 华东南赛区]Double Secret
  • Android WebView 中网页被劫持的原因及解决方案
  • 特朗普政府将开展新网络攻击
  • 快递代取项目Uniapp+若依后端管理
  • arcgis短整型变为长整型的处理方式
  • 06、Redis相关概念:缓存击穿、雪崩、穿透、预热、降级、一致性等
  • 嵌入式基础 -- PCIe 控制器中断管理之MSI与MSI-X简介