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

相关推荐
fangjianj13 分钟前
windows环境反弹shell
linux·windows·web安全
明月不会写代码24 分钟前
Ubuntu 下 Kitty 终端配置记录
linux·ubuntu
weipt38 分钟前
利用wsl给windows电脑上安装一个ubuntu
linux·运维·ubuntu
jarreyer1 小时前
【软件操作】加快资源管理器打开速度
运维
xiaoye-duck1 小时前
《Linux 网络编程》深入理解 TCP 协议(二):序号、确认应答与流量控制机制详解
linux·网络·tcp
楚疏笃1 小时前
linux下给OpenCloudOS根目录扩容
linux·运维·服务器
dog2501 小时前
网络的时延抖动
linux·运维·网络
阿钱真强道1 小时前
01 嵌入式操作系统 | 课程导论与虚拟机安装 Ubuntu
linux·ubuntu·嵌入式·虚拟机
程序员-Benothing2 小时前
Linux 软件包管理:yum / apt / dnf 命令使用全解析
linux·运维·服务器
GeW2 小时前
拿RHCE证书只是起点:这样备考,顺便把真实运维能力也练了
linux