你好,游客 登录 注册 搜索
背景:
阅读新闻

Nginx静态服务器简单实现

[日期:2017-02-21] 来源:Linux社区  作者:215687833 [字体:大 中 小]

生产环境是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的文章您也可能喜欢,不妨参考下:

CentOS 7.2下编译安装PHP7.0.10+MySQL5.7.14+Nginx1.10.1  http://www.linuxidc.com/Linux/2016-09/134804.htm

搭建基于Linux6.3+Nginx1.2+PHP5+MySQL5.5的Web服务器全过程 http://www.linuxidc.com/Linux/2013-09/89692.htm

Linux下编译安装Nginx 1.8.1 及配置 http://www.linuxidc.com/Linux/2017-02/140495.htm

CentOS 6.4安装配置Nginx+Pcre+php-fpm http://www.linuxidc.com/Linux/2013-08/88984.htm

Nginx日志过滤 使用ngx_log_if不记录特定日志 http://www.linuxidc.com/Linux/2014-07/104686.htm

Nginx的500,502,504错误解决方法 http://www.linuxidc.com/Linux/2015-03/115507.htm

CentOS 7 编译安装Nginx1.10.2 脚本启动失败解决思路 http://www.linuxidc.com/Linux/2017-01/139794.htm

Nginx 的详细介绍:请点这里
Nginx 的下载地址:请点这里

本文永久更新链接地址:http://www.linuxidc.com/Linux/2017-02/140868.htm

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款