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配置是一样的

相关推荐
不会就选b10 分钟前
Linux之线程池(三)
linux·开发语言
Sylvia-girl15 分钟前
【一】:Linux基础指令
linux·运维·服务器
KKKlucifer28 分钟前
运维域与IT域融合——云网安全一体化运营体系建设
大数据·运维·安全
0+11140 分钟前
Linux --基础IO
linux·运维·服务器
资深电气设计44 分钟前
雕铣机主轴驱动升级趋势分析:变频器技术价值与选型逻辑探讨
运维
M78佐菲1 小时前
Linux多线程:创建、回收与互斥同步
linux·笔记·学习·算法
名字还没想好☜1 小时前
Prometheus 告警实战:写 alerting rules、用 Alertmanager 做路由分组与抑制
运维·前端·javascript·docker·kubernetes·prometheus
sunoo-2291 小时前
【Linux 系统编程】学习第七天:线程属性 | 互斥锁 | 死锁 | 信号量 核心知识点 + 踩坑实战
linux·c语言·笔记·vscode·学习
Zkaisen1 小时前
【Gitee】SSH 公钥、GPG 公钥、私人令牌的区别
运维·gitee·ssh
小雪崩2 小时前
嵌入式学习 day33:线程进阶
linux·c语言·学习