nginx指定目录只允许内网访问
<pre><code>server {
listen 80;
listen 443 ssl;
ssl_certificate /data/conf/nginx/1_shiyue.com_bundle.crt;
ssl_certificate_key /data/conf/nginx/2_shiyue.com.key;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
server_name data-cleaner.shiyue.com;
root /data1/www/data-cleaner/public;
index index.php;
charset utf-8;
location ~* ^/(.*\.(sql|log|DS_Store|bak|backup|old|swp|htaccess)$|(\.svn/|\.git/)|(.*(workspace\.xml|database\.yml|web\.config|web\.xml|package\.json|installed\.json|composer\.lock|phpinfo\.php|Dockerfile|package-lock\.json)$)) {
deny all;
}
access_log /data/logs/nginx_access.log;
error_log /data/logs/nginx_error.log;
location ~ /storage/charge-monitor/.*\.html$ { #主要是这里的配置
allow 113.108.148.74;
deny all;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~.*\.(swf|xml|mp3|png|jpg|gif|data)$ {
expires max;
}
location ~.*\.(css|js|mx)$ {
expires 96h;
}
location ~ /.svn/ {
deny all;
}
location ~ .php { # 为了支持pathinfo,需将包含.php的URL交给fastcgi解析,同时需设置php.ini中的cgi.fix_pathinfo=1
expires off;
access_log /data/logs/data-cleaner.shiyue.com.log json;
include fastcgi.conf;
fastcgi_pass 127.0.0.1:10081;
fastcgi_index index.php;
fastcgi_param PATH_INFO $fastcgi_script_name;
}
}</code></pre>