Nginx-6 动静不分离
2020-01-10 本文已影响0人
Habit_1027
环境
负载均衡器----------10.3.134.72
应用服务器----------10.3.134.99
image.png
一. 应用服务器上 配置 uwsgi
image.png[uwsgi]
socket = 0.0.0.0:9090 ;监听地址
chdir = /opt/webapp/ ;程序主目录
wsgi-file = wsgi.py ; 程序启动文件
processes = 4
threads = 2
stats = 127.0.0.1:9191
注意这里必须是
socket
二. 启动应用程序的服务
[root@mpn-salve webapp]# uwsgi qf-uwsgi.ini
三. 配置负载均衡器
image.png[root@mpn-master nginx]# vim /etc/nginx/nginx.conf
user nginx;
worker_processes 2;
#error_log logs/error.log;
worker_rlimit_nofile 102400;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
server {
listen 80;
server_name www.ddd.com;
location / {
include uwsgi_params;
uwsgi_pass 10.3.134.99:9090;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /dingdang/;
}
}
}
四. 启动负载均衡器
nginx -s reload
五. 访问负载均衡器的地址
[root@mpn-master nginx]# curl 10.3.134.99
<html>
<head>
<meta charset="utf-8">
<title>www.testdl.com</title>
</head>
<body style="background-color:orange;">
<img src="http://10.3.134.111/king.jpg"/>
</body>
</html>
浏览器访问:
http://10.3.134.99/info