Linux中nginx.conf如何配置【搬代码】

Nginx 是一个独立的软件。

它是一款高性能的 Web 服务器、反向代理服务器和负载均衡器等,具有强大的功能和广泛的应用场景。它通常需要单独进行安装和配置来发挥其作用。

下载网址:http://nginx.org/en/download.html

nginx.conf写法:

java 复制代码
#配置权重
upstream byeng{
		server 192.168.31.25:8585 weight=1;
		server 192.168.31.25:8586 weight=1;
	}
upstream bya{
		server 192.168.31.25:8585 weight=1;
		server 192.168.31.25:8586 weight=1;
	}
server {
        listen       80;
        server_name  localhost;

        location / {
            root   html;
            index  index.html index.htm;
			#此处nginx是跳上面upstream byeng权重
			proxy_pass http://byeng; 
        }	


		#byeng后面加/,http后面有端口端口后面也要加/
		location /byeng/ {
			proxy_pass http://192.168.31.25:8585/;
		}
		#也可以这样写
		location /a/ {
			proxy_pass http://bya/; 
		}
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

    }
java 复制代码
upstream bya{
		server 192.168.31.25:8585 weight=1;
		server 192.168.31.25:8586 weight=1;
	}
	
server{

 		listen       80;
        server_name  localhost;

        location / {
            root   html;
            index  index.html index.htm;
        }	
	#也可以这样写
		location /a/ {
			proxy_pass http://bya/; 
		}
}


其实Linux和window配置是一样的

相关推荐
楚识科技5 分钟前
合同比对全流程自动化:OCR识别+差异比对+法律风险字段抽取实战指南
运维·自动化·ocr
代码方舟18 分钟前
零信任架构实战:基于天远人企关联构建自动化供应链金融网关
运维·人工智能·架构·自动化
Lsetea1 小时前
OpenSSL verify报error 20:CAfile、fullchain与本地信任链分层排查
nginx·https·ssl证书·openssl·证书链
贵沫末1 小时前
Ubuntu——常用软件安装
linux·运维·ubuntu
Doraemomo2 小时前
Linux内核驱动开发——中断与定时器
linux·运维·驱动开发
2301_808414382 小时前
Linux中动静态库的理解
linux·运维·服务器
分布式存储与RustFS2 小时前
模型 checkpoint 放对象存储:分片上传、断点续传与残留清理
运维·云原生·开源·对象存储·分布式存储·s3·性能基准
M78佐菲3 小时前
ARM学习笔记(11)
linux·arm开发·笔记·嵌入式硬件·学习
M78佐菲3 小时前
ARM学习笔记(10)
linux·arm开发·笔记·嵌入式硬件·学习
半仙白桑3 小时前
内核篇第十五讲:system-V共享内存
linux·共享内存·shmget·shmat·shmdt·shmctl