Nginx配置

2019-04-03  本文已影响0人  abu2013

1,pathInfo 路径

server
    {
        listen 8080;
        #listen [::]:80;
        server_name 139.196.137.253 ;
        index index.html index.htm index.php default.html default.htm default.php;
        root  /home/wwwroot/www.freeenjoy.com;
        include other.conf;
        #error_page   404   /404.html;
        # Deny access to PHP files in specific directory
        #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }
        #支持ThinkPHP pathInfo路径 注释include enable-php.conf; 添加include enable-php-pathinfo.conf;
        #include enable-php.conf;
        include enable-php-pathinfo.conf;

        #设置访问文件夹列表,注释后怎为 403 forbidden
        location ~ /*
        {
                   autoindex on;
                   autoindex_exact_size off;
                   autoindex_localtime on;
        }
        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

          location ~ [^/]\.php(/|$)
        {
            #try_files $uri =404;
            fastcgi_pass  unix:/tmp/php-cgi.sock;
            fastcgi_index index.php;
            include fastcgi.conf;
            include pathinfo.conf;
        }
        access_log  /home/wwwlogs/www.freeenjoy.com.log;
    }

2,隐藏端口号

server {
    listen 80;
    server_name www.up.com;
    location / {
            proxy_set_header X-Forwarded-For $remote_addr;
            proxy_set_header Host            $http_host;
            proxy_pass   http://127.0.0.1:1031;
    }
}
proxy_set_header Host $proxy_host;

参考1

上一篇 下一篇

猜你喜欢

热点阅读