工作生活

nginx 学习笔记

2019-07-02  本文已影响0人  犯色戒的和尚
# user nobody;
worker_processes 1;
error_log logs/error.log;
error_log logs/error.log  notice;
error_log logs/error.log  info;
# pid logs/nginx.pid;
events {
    worker_connections 1024;
}
http {
    include mime.types;
# include servers/*;
    default_type application/octet-stream;
    log_format main  '$remote_addr - $remote_user [$time_local] "$request" '
                 '$status $body_bytes_sent "$http_referer" '
                 '"$http_user_agent" "$http_x_forwarded_for"';
    access_log logs/access.log  main;
    sendfile on;
    keepalive_timeout 60;
    server {
        listen 8000;
        server_name _;
        access_log logs/host.access.log  main;
        location / {
            root /Users/litengfei/Desktop/gps-transfer-web/dist;
            index index.html;
            try_files $uri $uri/ /index.html;
        }
        location /apis/ {
            include uwsgi_params;
            proxy_pass http://127.0.0.1:5050/;
            add_header Access-Control-Allow-Origin *;
            add_header Access-Control-Allow-Headers X-Requested-With;
            add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
            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;
            proxy_connect_timeout 5;
        }
        location = /50x.html {
            root html;
        }
        error_page 404              /404.html;
        error_page 500 502 503 504  /50x.html;
    }
}

上一篇 下一篇

猜你喜欢

热点阅读