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";

}

}

相关推荐
xu_yule5 小时前
Linux_12(进程信号)内核态和用户态+处理信号+不可重入函数+volatile
linux·运维·服务器
虾..5 小时前
Linux 环境变量&&进程优先级
linux·运维·服务器
i***t9195 小时前
Linux下MySQL的简单使用
linux·mysql·adb
偶像你挑的噻5 小时前
11-Linux驱动开发-I2C子系统–mpu6050简单数据透传驱动
linux·驱动开发·stm32·嵌入式硬件
稚辉君.MCA_P8_Java6 小时前
DeepSeek 插入排序
linux·后端·算法·架构·排序算法
zhuyasen7 小时前
Go Web 开发利器:如何让你的 Gin 服务拥有 Nginx 般的静态文件处理能力?
nginx·go·gin
achi0107 小时前
Ubuntu 24.04 LTS 下 Vue 3 开发环境搭建与生产部署完整指南
nginx·node·nvm·vue 3·ubuntu 24·开发环境搭建·国内镜像仓库
郝学胜-神的一滴8 小时前
Linux命名管道:创建与原理详解
linux·运维·服务器·开发语言·c++·程序人生·个人开发
宾有为8 小时前
【Linux】Linux 常用指令
linux·服务器·ssh
wdfk_prog8 小时前
[Linux]学习笔记系列 -- [block]bio
linux·笔记·学习