mac local web ngnix proxy

代理本地website步骤:

1.写入hosts,才能将请求发到本地:

sudo vi /etc/hosts

2.配置vhost ngnix xxxxx.conf:

server {
    listen 80;
    server_name xxx.xxx.com;
    set $node_port 8081;
    location ~* /{
        proxy_http_version 1.1;
        proxy_set_header Connection "";
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-NginX-Proxy true;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_pass http://127.0.0.1:$node_port$request_uri;
        proxy_redirect off;
    }
}

3.运行ngnix:

ngnix -s stop
ngnix
ps -ef|grep ngnix

你可能感兴趣的:(mac local web ngnix proxy)