【nginx】配置

 

http://www.yinxi.net/zt/show.php?ztID=11015

http://www.yinxi.net/zt/show.php?ztID=11015

https://stackoverflow.com/questions/38346847/nginx-docker-container-502-bad-gateway-response

https://www.cnblogs.com/niceyoo/p/11546370.html

https://www.jianshu.com/p/b010c9302cd0

https://www.jianshu.com/p/fbfd08ab5527

 https://segmentfault.com/a/1190000013007649

https://www.jianshu.com/p/b010c9302cd0

 https://blog.csdn.net/jtbrian/article/details/78183433

 https://blog.csdn.net/xiaoxiangzi520/article/details/78737527

 

https://www.datadoghq.com/blog/nginx-502-bad-gateway-errors-gunicorn/#nginx-is-misconfigured

server {
listen 80;
server_name ××××.com;
access_log /×××/×××/nginx/log/access.log;
error_log /×××/×××/nginx/log/error.log;

location / {
proxy_pass http://127.0.0.1:8000;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /static {
alias /×××/×××/×××/×××/static/;
expires 30d;
}
location /neo4j {
proxy_pass http://127.0.0.1:7474/browser/;
}
}

 

worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       8080;
        listen       80;
        server_name  localhost 888888.com 192.168.1.104;

        # Vue路由模式为history需添加的配置
        location / {
            if (!-e $request_filename) {
                rewrite ^(.*)$ /index.html?s=$1 last;
                break;
            }
            root   /home/nginx/www;
            index  index.html;
        }

        # 获取真实IP以及Websocket需添加的配置
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header REMOTE-HOST $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";

        # 客户端Body大小限制(文件上传大小限制配置)
        client_max_body_size 5m;
    }

server {
        listen 8000;
        server_name 888888.com localhost;
        access_log /home/nginx/log/access.log;
        error_log /home/nginx/log/error.log;

        location / {
			if ($request_method = OPTIONS ) {
                    add_header Access-Control-Allow-Origin http://www.88888.com:8000;
                    add_header Access-Control-Allow-Headers Origin,X-Requested-With,Content-Type,Accept;
                    return 200;
                }
	        proxy_pass http://127.0.0.1:5000;
	        proxy_redirect off;
	        add_header Access-Control-Allow-Origin http://www.88888.com:8000 always;
	        add_header Access-Control-Allow-Headers 'X-Requested-With,content-type' always;
	        add_header Access-Control-Allow-Methods 'GET,POST,OPTIONS,DELETE' always;
        }
    }

}



sudo docker run -it -d --name nginx -p 8080:8080 -p 80:80 -p 8000:8000  -v /home/ubuntu/dapengV2/docker/nginx/conf/nginx.conf:/etc/nginx/nginx.conf -v /home/ubuntu/dapengV2/frontend/dist:/home/nginx/www -v /home/ubuntu/dapengV2/docker/nginx/log:/home/nginx/log  nginx



nohup gunicorn --workers=2 --timeout=600 wsgi:app &

  

 

posted on 2020-02-02 22:51  colipso  阅读(134)  评论(0编辑  收藏  举报

导航