首页 > 服务器 > nginx反向代理配置
作者:ghostry 发布时间:2016-09-07 浏览: 3565
转载注明出处: https://blog.1ge.fun/server/734.html首先是安装nginx,
apt-get install nginx
然后vim /etc/nginx/sites-available/mysite
proxy_cache_path /data/nginx/cache/webserver levels=1:2 keys_zone=webserver:20m max_size=1g;
server {listen 80; access_log /var/log/nginx/vsj.access.log; error_log /var/log/nginx/vsj.error.log; proxy_buffers 16 64k; proxy_buffer_size 128k; location / { proxy_pass http://后端域名; proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; 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 http; proxy_cache webserver; proxy_cache_valid 200 10m; }
}
然后
ln -s /etc/nginx/sites-available/mysite /etc/nginx/sites-enabled
rm /etc/nginx/sites-enabled/default
mkdir -pv /data/nginx/cache/webserver
systemctl restart nginx
完成。
上一篇: 超方便的动静分离下一篇: you name 你的名字 君的名