阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

Nginx静态服务器简单实现

125次阅读
没有评论

共计 1891 个字符,预计需要花费 5 分钟才能阅读完成。

生产环境是 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 静态服务器简单实现

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

下面关于 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

正文完
星哥说事-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-21发表,共计1891字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中