码迷,mamicode.com
首页 > 其他好文 > 详细

Nginx 静态服务器

时间:2017-02-08 16:22:22      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:nginx 静态服务器

生产环境是2台,我这测试就一台。


动静分离:

nginx_static server:192.168.121.128

nginx_server :192.168.121.133


静态文件服务器配置:

[root@192 conf.d]# cat static.conf 
server {
    listen       80 default_server;  #default_server
    server_name  _;#ip访问
    location /{
        root   /data/company/;#静态文件存放的目录
        index  index.html index.htm;
    }
}



#nginx_static映射的目录文件存放路径

[root@192 conf.d]# ls /data/company/
aboutUs.html                 img             messageCloud.html  news-solution.html     priceCloud.html     solutionO2O.html
bak                          index.html      min-system.html    news-trends.html       privateCloud.html   trackCloud.html
companyWebsite-20170111.zip  ITservice.html  newDetail.html     operationPerson.html   solutionB2B2C.html  WMS.html
css                          joinUS.html     news               operationsCourse.html  solutionB2B.html
fonts                        js              news.html          operationSystem.html   solutionB2C.html

nginx服务器代理:

[root@localhost conf.d]# cat upstream.conf 
upstream company {
server 192.168.121.128:80;
}
[root@localhost conf.d]# cat zabbix.test.conf 
server {
listen       80;
        server_name  zabbix.test.com;
location / {
index index.html;
proxy_pass http://company;#upstream
proxy_set_header   Host    $host;   #nginx主机头
proxy_set_header   X-Real-IP   $remote_addr;
proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
}
}


效果图:

技术分享

生产域名的话,在万网做个解析就好了!


本文出自 “LINUX Super梦” 博客,请务必保留此出处http://215687833.blog.51cto.com/6724358/1896045

Nginx 静态服务器

标签:nginx 静态服务器

原文地址:http://215687833.blog.51cto.com/6724358/1896045

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!