nginx不提供html文件

时间:2019-12-11 19:28:35

标签: nginx

我开始尝试开发DevOps的东西,并获得了带有ubuntu仿生海狸的服务器。我安装了nginx来托管一个基于React的网站。但是,由于我以前认为我会使用php,所以我创建了以下nginx配置:

server {
  root /var/www/html;
  index index.php index.html index.htm;
  server_name example.com www.example.com *.example.com;

  location / {
          proxy_pass https://proxy.com;
          proxy_set_header Host $host;
          try_files $uri $uri/index.php;
          auth_basic "Restricted Content";
          auth_basic_user_file /etc/nginx/.htpasswd;
  }

  location ~ \.php$ {
          include snippets/fastcgi-php.conf;
          fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
  }

  location ~ /\.ht {
          deny all;
  }

listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot



}
server {
if ($host = www.example.com) {
  return 301 https://$host$request_uri;
} # managed by Certbot


if ($host = example.com) {
  return 301 https://$host$request_uri;
} # managed by Certbot


  listen 80;
  server_name example.com www.example.com *.example.com;
return 404; # managed by Certbot
}

我认为我需要更改位置/阻止try_files指令,并可能删除其他位置块。我到目前为止正确吗?因为执行此操作时会收到内部服务器错误。

我不确定如何有效地调试它。很高兴听到任何建议或更正。

亲切的问候

0 个答案:

没有答案