• Nginx 代理静态网站


    配置文件如下:

    #user  nobody; 
    worker_processes  1;
    
    error_log  logs/error.log;
    #error_log  logs/error.log  notice;
    #error_log  logs/error.log  info;
    
    #pid        logs/nginx.pid;
    
    worker_rlimit_nofile 65535;
    events {
        worker_connections  65535;
    }
    
    
    http {
        include       mime.types;
        default_type  application/octet-stream;
    
        #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
        #                  '$status $body_bytes_sent "$http_referer" '
        #                  '"$http_user_agent" "$http_x_forwarded_for"';
    
        #access_log  logs/access.log  main;
    
        sendfile        on;
        tcp_nopush     on;
        tcp_nodelay    on;
    
        #keepalive_timeout  0;
        keepalive_timeout  65;
    
        gzip  on;
    
        server {
            listen       80;
            server_name  localhost;
    
            #charset koi8-r;
    
            #access_log  logs/host.access.log  main;
    
            location /src {
                root   F:/测试静态网站/;
                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;
            }
    
            # proxy the PHP scripts to Apache listening on 127.0.0.1:80
            #
            #location ~ \.php$ {
            #    proxy_pass   http://127.0.0.1;
            #}
    
            # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
            #
            #location ~ \.php$ {
            #    root           html;
            #    fastcgi_pass   127.0.0.1:9000;
            #    fastcgi_index  index.php;
            #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            #    include        fastcgi_params;
            #}
    
            # deny access to .htaccess files, if Apache's document root
            # concurs with nginx's one
            #
            #location ~ /\.ht {
            #    deny  all;
            #}
        }
    
    
        # another virtual host using mix of IP-, name-, and port-based configuration
        #
        #server {
        #    listen       8000;
        #    listen       somename:8080;
        #    server_name  somename  alias  another.alias;
    
        #    location / {
        #        root   html;
        #        index  index.html index.htm;
        #    }
        #}
    
    
        # HTTPS server
        #
        #server {
        #    listen       443 ssl;
        #    server_name  localhost;
    
        #    ssl_certificate      cert.pem;
        #    ssl_certificate_key  cert.key;
    
        #    ssl_session_cache    shared:SSL:1m;
        #    ssl_session_timeout  5m;
    
        #    ssl_ciphers  HIGH:!aNULL:!MD5;
        #    ssl_prefer_server_ciphers  on;
    
        #    location / {
        #        root   html;
        #        index  index.html index.htm;
        #    }
        #}
    
    }

    主要关注http的location节点其配置如下:

            location /src {
                root   F:/测试静态网站/;
                index  index.html index.htm;
            }

    这里设置了根路径是 F:/测试静态网站/,并且首页设置了index.html、index.htm.  这里需要注意的是如下:

            location / {
                root   F:/测试静态网站/src/;
                index  index.html index.htm;
            }

    其实两者的效果是一样的.第一个和第二个指向的绝对路径不一样,但是第一个nginx会做拼接操作,相当于F:/测试静态网站/+src=root.

  • 相关阅读:
    计算fibonacci数(多种方法)
    数组求和(两种方法)
    C语言二级指针(指向指针的指针)
    唯品会海量实时OLAP分析技术升级之路
    hive 调优(一)coding调优
    supsplk 服务器被植入木马 挖矿 cpu使用 700%
    OPTS参数设置
    Yarn 内存分配管理机制及相关参数配置
    hive on tez 任务失败
    hive 调优(三)tez优化
  • 原文地址:https://www.cnblogs.com/GreenLeaves/p/16719780.html
Copyright © 2020-2023  润新知