【发布时间】:2019-03-22 01:25:31
【问题描述】:
我在使用 Nginx 为 NodeJS 应用程序配置服务器虚拟主机时收到 403 Forbidden。
配置文件代码:
server {
listen 443 default_server;
listen [::]:443 default_server;
ssl on;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
root /mnt/var/www/example.com/app/public/;
index index.html index.htm index.php;
server_name example.com www.example.com;
access_log /var/log/nginx/dygnostica_access.log;
error_log /var/log/nginx/dygnostica_error.log;
location / {
include /etc/nginx/proxy_params
try_files $uri $uri/ =404;
}
}
server {
listen 0.0.0.0:80;
server_name example.com www.example.com;
rewrite ^ https://$host$request_uri? permanent;
}
我已经根据this 文章设置了所有配置。
需要帮助解决 403。提前致谢。
编辑:
错误日志说:
“/mnt/var/www/example.com/app/public/”的目录索引被禁止。
【问题讨论】:
-
编辑您的问题并从您的访问日志和错误日志中添加相关条目。您问题中的代码缺少
;- 这只是问题或配置中的错字吗? -
@RichardSmith,我添加了错误日志。并且可能我需要提供此行的特定路径:“root /mnt/var/www/example.com/app/public/;”但我不知道如何给出确切的路径。
-
那么 nginx 是否有权查看该文件夹?
标签: node.js nginx error-handling virtualhost http-status-code-403