gpt4 book ai didi

node.js - 403禁止+ Nginx +虚拟主机配置+ NodeJS

转载 作者:行者123 更新时间:2023-12-03 08:46:30 25 4
gpt4 key购买 nike

我正在使用Nginx for 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/”被禁止。

最佳答案

我认为您对虚拟主机的配置错误。这是我的nginx配置文件。我在主域上具有标准PHP应用程序(https),在子域上具有节点应用程序(在端口3000上运行):

#// virtual host for node app:
server {
server_name node.domain.cz;
location / {
proxy_pass http://127.0.0.1:3000;
}
}

#// host (for PHP app)
server {
listen 80;
server_name domain.cz www.domain.cz;
root /var/www/domain.cz/www;
index index.php;

location / {
try_files $uri $uri/ /index.php?$args;
}

location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php/php7.1-fpm.sock;
fastcgi_index index.php;
include fastcgi.conf;
}

listen 443 ssl; # managed by Certbot
# ssl_certificate ...

if ($scheme != "https") {
return 301 https://$host$request_uri;
} # managed by Certbot

}

关于node.js - 403禁止+ Nginx +虚拟主机配置+ NodeJS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52853632/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com