nginx显示默认的欢迎页面而不是我的Web服务器上的目录

krcsximq  于 2023-10-17  发布在  Nginx
关注(0)|答案(1)|浏览(209)

我在远程Arch Linux服务器上安装了Nginx。我在/srv/http/mywebsite.com中有文件。(“mywebsite.com“当然只是我在这个问题中使用的占位符名称。
在那个目录中有一堆文件和页面。没有index.html。直到最近,我还可以通过访问mywebsite.com来查看目录中的所有文件。但是现在,在运行yay -Syyu升级和更新包,并删除/var/spool/clientmqueue中的文件后,当我转到mywebsite.com时,我只看到Nginx默认的“欢迎”页面。
以下是/etc/nginx/nginx.conf的内容。` #user http; worker_processes 1;

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;

  1. #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  2. # '$status $body_bytes_sent "$http_referer" '
  3. # '"$http_user_agent" "$http_x_forwarded_for"';
  4. #access_log logs/access.log main;
  5. sendfile on;
  6. #tcp_nopush on;
  7. #keepalive_timeout 0;
  8. keepalive_timeout 65;
  9. #gzip on;
  10. server {
  11. listen 80;
  12. server_name localhost;
  13. #charset koi8-r;
  14. #access_log logs/host.access.log main;
  15. location / {
  16. root /usr/share/nginx/html;
  17. index index.html index.htm;
  18. }
  19. #error_page 404 /404.html;
  20. # redirect server error pages to the static page /50x.html
  21. #
  22. error_page 500 502 503 504 /50x.html;
  23. location = /50x.html {
  24. root /usr/share/nginx/html;
  25. }
  26. # proxy the PHP scripts to Apache listening on 127.0.0.1:80
  27. #
  28. #location ~ \.php$ {
  29. # proxy_pass http://127.0.0.1;
  30. #}
  31. # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  32. #
  33. #location ~ \.php$ {
  34. # root html;
  35. # fastcgi_pass 127.0.0.1:9000;
  36. # fastcgi_index index.php;
  37. # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
  38. # include fastcgi_params;
  39. #}
  40. # deny access to .htaccess files, if Apache's document root
  41. # concurs with nginx's one
  42. #
  43. #location ~ /\.ht {
  44. # deny all;
  45. #}
  46. }
  47. # another virtual host using mix of IP-, name-, and port-based configuration
  48. #
  49. #server {
  50. # listen 8000;
  51. # listen somename:8080;
  52. # server_name somename alias another.alias;
  53. # location / {
  54. # root html;
  55. # index index.html index.htm;
  56. # }
  57. #}
  58. # HTTPS server
  59. #
  60. #server {
  61. # listen 443 ssl;
  62. # server_name localhost;
  63. # ssl_certificate cert.pem;
  64. # ssl_certificate_key cert.key;
  65. # ssl_session_cache shared:SSL:1m;
  66. # ssl_session_timeout 5m;
  67. # ssl_ciphers HIGH:!aNULL:!MD5;
  68. # ssl_prefer_server_ciphers on;
  69. # location / {
  70. # root html;
  71. # index index.html index.htm;
  72. # }
  73. #}

}/etc/nginx/sites-available/etc/nginx/sites-enabled中,我都有mywebsite.com,其内容如下.server { listen 443; ssl on; ssl_certificate/etc/ssl/cert_chain. crt; ssl_certificate_key /etc/ssl/myswebsite.com.key;

  1. server_name mywebsite.com www.mywebsite.com;
  2. access_log /var/log/nginx/nginx.vhost.access.log;
  3. error_log /var/log/nginx/nginx.vhost.error.log;
  4. location / {
  5. root /srv/http/mywebsite.com;
  6. index index.html;
  7. autoindex on;
  8. autoindex_exact_size off;
  9. if ($request_method = 'OPTIONS') {
  10. add_header 'Access-Control-Allow-Origin' '*';
  11. add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
  12. #
  13. # Custom headers and headers various browsers *should* be OK with but aren't
  14. #
  15. add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
  16. #
  17. # Tell client that this pre-flight info is valid for 20 days
  18. #
  19. add_header 'Access-Control-Max-Age' 1728000;
  20. add_header 'Content-Type' 'text/plain; charset=utf-8';
  21. add_header 'Content-Length' 0;
  22. return 204;
  23. }
  24. if ($request_method = 'POST') {
  25. add_header 'Access-Control-Allow-Origin' '*';
  26. add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
  27. add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
  28. add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
  29. }
  30. if ($request_method = 'GET') {
  31. add_header 'Access-Control-Allow-Origin' '*';
  32. add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
  33. add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
  34. add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
  35. }
  36. }

}`

euoag5mw

euoag5mw1#

我不熟悉arch Linux,但看起来你的nginx.conf并不包括支持站点的conf目录,例如:

  1. http {
  2. include mime.types;
  3. default_type application/octet-stream;
  4. include /etc/nginx/sites-enabled/*.*;
  5. <... rest of file ...>
  6. }

相关问题