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

相关推荐
peiwang24520 小时前
Linux系统中CoreDump的生成与调试
java·linux·开发语言
小立爱学习21 小时前
Linux 内存 --- get_user_pages/pin_user_pages函数
linux·c语言
江公望21 小时前
Qt enum ApplicationAttribute枚举值浅解
linux·qt
青鱼入云21 小时前
对比nginx、kong、apisix、zuul、gateway网关
nginx·gateway·kong
Yuki’21 小时前
Linux系统的ARM库移植
linux·arm开发
报错小能手21 小时前
linux学习笔记(51)Redis发布订阅 主从复制 缓存 雪崩
linux·笔记·学习
塔能物联运维1 天前
物联网运维中的容器化服务部署与弹性扩展技术
运维·物联网
程序猿编码1 天前
轻量级却实用:sigtrace 如何靠 ptrace 实现 Linux 信号的捕获与阻断(C/C++代码实现)
linux·c语言·c++·信号·捕获·ptrace
qq_393060471 天前
阿里云创建交换分区、设置内存监控预警和自动处理内存占用过大进程的脚本
linux·服务器·阿里云
Jtti1 天前
什么是DNS负载均衡?提升网站稳定性与容错性的方法
运维·负载均衡