nginx配置项目,配置文件及相应linux命令

云服务器安装nginx步骤

安装nginx:

yum install nginx

启动nginx:

nginx

停止nginx:

nginx -s stop

配置文件路径/etc/nginx/conf.d/

上传配置文件到这个目录下,然后重启nginx


配置文件(单云服务器配置单项目)

xxx.conf

server {

listen 8007;

server_name localhost;

location / {

root /opt/commeta-mng/;

index /index.html;

try_files $uri $uri/ /index.html;

}

#图片放置云服务器位置

location /pictures {

alias /data/pictures/;

}

location ^~ /commeta-upms {

proxy_pass http://ip:8000;

}

location ^~ /commeta-logic {

proxy_pass http://ip:8000;

}

location ^~ /commeta-im {

proxy_pass http://ip:8000;

}

location /commeta-socket/ {

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_set_header Host $host;

proxy_pass http://ip:8004;

proxy_http_version 1.1;

proxy_set_header Upgrade $http_upgrade;

proxy_set_header Connection "upgrade";

}

}

配置文件(服务高可用的多云服务器配置2个项目)

高可用xxx.conf

upstream commeta-socket {

least_conn ; #使用最小连接

server 10.8.55.15:8000 ;

server 10.8.55.16:8000 ;

}

server {

listen 8007;

server_name localhost;

location /partybuilding/ {

alias /opt/partybuilding-ui/;

index index.html;

try_files $uri $uri/ /partybuilding/index.html;

}

location /commeta-mng/ {

alias /opt/commeta-mng-ui/;

index index.html;

try_files $uri $uri/ /commeta-mng/index.html;

}

location ^~ /commeta-upms {

proxy_pass http://commeta-socket;

}

location ^~ /commeta-logic {

proxy_pass http://commeta-socket;

}

location ^~ /commeta-im {

proxy_pass http://commeta-socket;

}

location /commeta-socket/ {

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_set_header Host $host;

proxy_pass http://commeta-socket;

proxy_http_version 1.1;

proxy_set_header Upgrade $http_upgrade;

proxy_set_header Connection "upgrade";

}

}

相关推荐
XY.散人15 分钟前
初识Linux · 文件(1)
linux·运维·服务器
叶北辰CHINA1 小时前
nginx反向代理,负载均衡,HTTP配置简述(说人话)
linux·运维·nginx·http·云原生·https·负载均衡
不惑_2 小时前
在 Ubuntu 安装 Python3.7(没有弯路)
linux·运维·ubuntu
Lansonli3 小时前
云原生(四十八) | Nginx软件安装部署
nginx·云原生·ecs服务器
玉树临风江流儿3 小时前
Linux驱动开发(速记版)--设备模型
linux·驱动开发
杰哥在此3 小时前
Python知识点:如何使用Multiprocessing进行并行任务管理
linux·开发语言·python·面试·编程
枫叶丹45 小时前
【在Linux世界中追寻伟大的One Piece】进程信号
linux·运维·服务器
刻词梨木5 小时前
ubuntu中挂载点内存不足,分配不合理后使用软链接的注意事项
linux·运维·ubuntu
灯火不休ᝰ6 小时前
[win7] win7系统的下载及在虚拟机中详细安装过程(附有下载文件)
linux·运维·服务器
加油,旭杏9 小时前
【中间件学习】fastCG介绍和使用
学习·nginx·fastcgi