nginx 访问静态html 方式

1.nginx 配置:


user  nginx nginx;
worker_processes  8;
worker_cpu_affinity 00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000000;
worker_rlimit_nofile 65536;
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  65536;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr [$time_local] $upstream_addr $upstream_status $upstream_response_time "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent"';
    log_format cachelog '$time_local - $upstream_cache_status - Cache-Control:$upstream_http_cache_control - $request($status) - ';

    access_log  logs/access.log  main;

    sendfile        on;
    tcp_nopush     on;
    proxy_ignore_client_abort on;

    keepalive_timeout  65;
    #keepalive_timeout  1000;
    charset utf-8;
    gzip on;
    gzip_min_length 10k;
    gzip_buffers 4 16k;
    gzip_comp_level 2;
    gzip_types text/plain text/javascript application/javascript application/x-javascript text/css  application/xml application/octet-stream;
    gzip_vary on;
    
    server {

#被监听的端口号和网址

        listen       80;

        server_name  www.test.com;

        #charset koi8-r;

        access_log  logs/test_access.log  main;

        location / {

        #这个地方指定被访问的文件夹位置

            root   /data/test;
            index  index.html index.htm;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|css|js)$ {
        root /data/test;
        expires 30d;
        }
    }

    
    #location ~ /purge(/.*){
    #    allow 192.168.0.0/16;
    #    deny all;
    #    proxy_cache_purge resource $host$1$is_args$args;
    #}
    }

你可能感兴趣的:(nginx 访问静态html 方式)