首页 > 服务器 > nginx反向代理配置

作者:ghostry 发布时间:2016-09-07 浏览: 1276

转载注明出处: https://blog.ghostry.cn/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

完成。

标签: ubuntu nginx

上一篇: 超方便的动静分离
下一篇: you name 你的名字 君的名

添加新评论 »

*
*

欢迎评论!歡迎評論!Comments welcome!komentoj bonvenaj!댓글 오신 것을 환영합니다!
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: :cold: :cryy: :cute: :shy: :sleep: :struggle: :tea: :yahou: