Nginx简单配置反向代理

发布于 2018-06-09  202 次阅读


HTTP

server
{
 listen 80;
 server_name xxx.com;
 
 location / {
 proxy_pass http://mubiao.com
 proxy_set_header X-Forwarded-For $remote_addr;
 proxy_set_header Host "mubiao.com";
 }
}

HTTPS

server {
         listen 443 ssl;
ssl on;
        ssl_certificate /etc/letsencrypt/live/XXX.net/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/XXX.net/privkey.pem;
        server_name xxx.net;

         location / {
        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_pass  https://mubiao.net/;
    }

}


LoneKing