nginx 静态服务器设置

一、配置Nginx

[root@VM_16_15_centos nginx]# cd conf.d/
[root@VM_16_15_centos conf.d]# ll
total 4
-rwxr-xr-x 1 root root 693 Mar  7 13:48 image.conf
[root@VM_16_15_centos conf.d]# vim image.conf
server {
        listen 80;
        server_name img.intebox.com;
        root /mnt/ipower365/apache-tomcat7/webapps;

       location ~  ^/img/imgs/roomRegister/(.*).(jpg|jpeg|png|bmp|swf)$ {
                add_header content-type "image/png";
                alias /mnt/ipower365/apache-tomcat7/webapps/img/imgs/roomRegister/$1;
         }

       location ~ ^/img/imgs/roomRegister/ {
                add_header content-type "image/png";

        }

       location ~ .*.(jpg|jpeg|gif|png|bmp|webp)$ {
                root /mnt/ipower365/apache-tomcat7/webapps;
        }
       location /img {
                root /mnt/ipower365/apache-tomcat7/webapps;
        }
}

 二、配置NFS

1、在img.intebox.com服务器vi  /etc/exports
#sassbill10
/mnt/ipower365/apache-tomcat7/webapps/img 172.17.0.11(rw,sync,no_root_squash)
2、在客户端/etc/hosts中添加 10.168.229.169 img.intebox.com
3、[client]yum install nfs-utils rpcbind
4、[service]service nfs restart(重启)
5、[client]/etc/init.d/rpcbind start
6、[client]mount -t nfs  img.intebox.com:/mnt/ipower365/apache-tomcat-7.0.55/webapps/img /mnt/ipower365/img
原文地址:https://www.cnblogs.com/zhangqigao/p/8559431.html