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

相关推荐
爱就是恒久忍耐几秒前
Ubuntu解决pip3安装库提示This environment is externally managed的问题
linux·python·ubuntu
闲猫4 分钟前
SSH 黑屏配置试用环境机器,受限bash和自定义shell
运维·ssh·bash
北执南念13 分钟前
Docker实用篇2
运维·docker·容器
古道青阳16 分钟前
构建工业级短视频生成流水线:Playwright + FFmpeg 自动化指南
运维·自动化·音视频
Surpass-HC16 分钟前
gsoap搭建网络像机onvif服务器
linux·服务器·数据库
Ameilide21 分钟前
Linux 应用软件编程 文件编程(IO)
linux·运维·服务器
枕星而眠25 分钟前
Linux IO多路复用:select、poll、epoll 核心原理与进阶实战
linux·运维·服务器·c++·后端
Rain50930 分钟前
GitLab-Runner + AI 代码审查服务 + 远程大模型 全套部署运维实战
linux·运维·人工智能·python·ci/cd·gitlab·ai编程
只看不学32 分钟前
jenkins+Kubernetes实现流水线CI/CD 接口自动化测试
运维·ci/cd·jenkins
冷色调的咖啡师32 分钟前
4.大数据高可用
大数据·linux·hadoop·hdfs·zookeeper·yarn