Linux ·

Nginx静态服务器简单实现

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

Nginx动静分离:

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;
}
}

效果图:

Nginx静态服务器简单实现 Linux 第1张

生产域名的话,在域名注册商那里做个解析就好了!

下面关于

参与评论