問題
我有一個用 NextJS 開發的網站,它在 Nginx 的服務器上運行。網站檔案位于 public_html 檔案夾中并在埠 3004 上運行,我有一個 proxy_pass 將請求重定向到埠 3004 上的 NextJS 網站。
但是當我在 google 上搜索我的域或我的網站時,它會顯示在結果中:Index of / (and the files inside)
例如,我想洗掉這個(以及里面的所有檔案串列)只放 Home - Domain。
研究和發布照片

我的 next.conf 檔案
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
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 /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 4096;
include /etc/nginx/mime.types;
default_type application/octet-stream;
include /etc/nginx/conf.d/*.conf;
server {
listen 80;
listen [::]:80;
server_name _;
root /usr/share/nginx/html;
include /etc/nginx/default.d/*.conf;
error_page 404 /404.html;
location = /404.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
server {
listen 80;
server_name computadorsolidario.tec.br www.computadorsolidario.tec.br;
location / {
autoindex off;
proxy_pass http://localhost:3004;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
}
}
}
我該如何解決這個問題?
uj5u.com熱心網友回復:
您可以關閉 nginx 在其中創建目錄串列的功能:
autoindex off;
如果要將“index if /”替換為實際的主頁,則需要index.html在檔案根目錄中創建一個檔案。
uj5u.com熱心網友回復:
您還應該在 conf 中添加為最后一個位置
location ~ /\. {
deny all;
}
阻止對點檔案 .env 檔案或其他敏感資料的檔案訪問
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/409325.html
標籤:
