nginx设置目录浏览及中文乱码问题解决方案
在Nginx下默认是不允许列出整个目录的。如需此功能,
先打开nginx.conf文件,在location server 或 http段中加入
autoindex on;
另外两个参数最好也加上去:
autoindex_exact_size off;
默认为on,显示出文件的确切大小,单位是bytes。
改为off后,显示出文件的大概大小,单位是kB或者MB或者GB
autoindex_localtime on;
默认为off,显示的文件时间为GMT时间。
注意:改为on后,显示的文件时间为文件的服务器时间
nginx设置目录浏览及中文乱码问题解决方案
但是如果有中文目录的话会出现乱码问题,所以还需要在下面添加这一句:
charset utf-8,gbk;
另外两个参数最好也加上去:
autoindex_exact_size off;
默认为on,显示出文件的确切大小,单位是bytes。
改为off后,显示出文件的大概大小,单位是kB或者MB或者GB
autoindex_localtime on;
默认为off,显示的文件时间为GMT时间。
改为on后,显示的文件时间为文件的服务器时间
完整的配置文件nginx.conf例子如下:
[root@localhost sbin]# cat ../conf/nginx.conf user root; worker_processes 2; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; autoindex on; autoindex_exact_size off; autoindex_localtime off; charset utf-8,gbk; #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; #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 / { root /var/www; index index.cgigo; } #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; # } #} }
相关推荐
Nginx禁止目录列出配置 Nginx禁止目录列出配置 在PHP网站中,在没有进行配置的情况下,攻击者可以通过在网址后面加上“../”或者“/*53.pdf”等语句来读取网站目录,这是不利于服务器和网站安全的。 Nginx禁止目录列...
有时候需要访问服务器上的一些静态资源,比如挂载其他设备上的图片到本地的目录,而本地的目录不在nginx根目录下,这个时候就需要简单的做一下目录映射来解决,比如想通过浏览器... location /image/ { ...
为了节约成本,很多时候一台server 的nginx可能要部署多个前端的情况,本实例是在docker环境下部署两个前端,同时处理前端调用后端跨域问题,本示例为阿里云centos7 系统docker20.10.6环境下nginx1.19.5版本 ...
nginx autoindex美化,目录树美化,linux文件浏览器,不同的实现方式和样式,多种选择
查看nginx容器一直都是退出状态
今天在do的VPS配置Nginx虚拟主机时,修改配置文件后,重启Nginx后一直报告失败,但是不知道哪里错了,直觉觉得是配置文件配置错了,google了下解决方案。 解决方案 Nginx启动或重启失败,一般是因为配置文件出错了,...
docker部署nginx,挂载多个前端部署目录以及跨域问题解决方案(1).zip
在本篇文章里小编给各位分享了关于nginx怎么解决跨域问题的方法和实例代码,需要的朋友们参考下。
主要介绍了在Nginx浏览器中打开目录浏览功能,Nginx的目录浏览功能默认情况下被关闭需要手动打开,需要的朋友可以参考下
Web应用安全:Nginx禁止目录列出配置实验.doc
ASP.NET导出Excel乱码的终极解决方案
Nginx 502 bad gateway问题的解决方法,希望能帮忙大家
lnmp环境中nginx的rwrite规则配置
基于ELK的nginx-qps监控解决方案.docx
nginx官方文档中文版
1、修改config/index.js 2、修改路由route/index ...以上这篇解决vue项目nginx部署到非根目录下刷新空白的问题就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持软件开发网。
最近因为工作需要,要将Nginx网站根目录更改下,通过网上的一些教程更改后,但发现测试的时候一直提示403 forbidden错误,后台通过一个朋友的提示也解决了,所以现在将详细的步骤分享给大家,有需要的朋友们可以参考...
一、什么是跨域问题 在一个服务器A里放置了json文件,另一个服务器B想向A发送ajax请求,...解决方案有不少,比较好的是服务器端配置CORS,但要求服务器端做更改。如果在不需要更改服务器端的情况下解决呢?尤其是需要在
Nginx安装的时候不指定安装目录,会默认安装到/usr/local/nginx下,因此如果需要改变安装目录的同学,可以按照以下方法安装。
Nginx+Tomcat负载均衡解决方案,当前信息系统的应用范围越来越广泛,我们的信息系统从开始的只需向少量用户提供服务,到现在越来越频繁的需要应对大量用户同时在线,系统高并发的情况也越来越常见,并且对系统的稳定...