美文网首页
Nginx-6 动静不分离

Nginx-6 动静不分离

作者: Habit_1027 | 来源:发表于2020-01-10 10:01 被阅读0次

    环境
    负载均衡器----------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

    image.png

    相关文章

      网友评论

          本文标题:Nginx-6 动静不分离

          本文链接:https://www.haomeiwen.com/subject/rcosactx.html