【Nginx】 server 配置记录
生活随笔
收集整理的這篇文章主要介紹了
【Nginx】 server 配置记录
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
根路徑禁止訪問,二級路徑使用目錄瀏覽功能
server{....location / {return 403;}# 使用正則location ~* ^/.*/(.*(xlsx|csv))?$ {autoindex on;autoindex_localtime on;}..... }root 與 alias 區別
官方手冊:http://nginx.org/en/docs/http/ngx_http_core_module.html#root
https://www.cnblogs.com/kevingrace/p/6187482.html
一般情況下,在nginx配置中的良好習慣是: 1)在location / 中配置 root目錄; 2)在location /path 中配置 alias虛擬目錄。 server {listen 80;server_name www.wangshibo.com;index index.html index.php index.htm;access_log /usr/local/nginx/logs/image.log;location / {root /var/www/html;}# 匹配的path目錄haha不需要真實存在alias指定的目錄中location /haha { # 后面的"/"符號一定要帶上,# 訪問 http://www.a.com/huan/a.html 實際指定的是 /var/www/html/ops/a.html。alias /var/www/html/ops/; }# 匹配的path目錄wang一定要真實存在root指定的目錄中(就/var/www/html下一定要有wang目錄存在)location /wang { root /var/www/html;}# 訪問http://www.wangshibo.com/web的時候就會去/home/www/html/下尋找訪問資源。# 這樣的話,還不能直接改成root目錄配置location /web/ {alias /home/www/html/;}# 如果非要改成root目錄配置,就只能在/home/www下將html->web(做軟連接,即快捷方式),如下:location /web/ {root /home/www/;}# ln -s /home/www/web /home/www/html //即保持/home/www/web和/home/www/html內容一直}總結
以上是生活随笔為你收集整理的【Nginx】 server 配置记录的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【Web】HTTPS 引入http资源,
- 下一篇: 【Nignx】 nginx启动http服