[英]Deploying Angular 6 app on Nginx - Forbidden
我正在尝试使用Nginx部署Angular应用程序
这是我的nginx conf:
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name mysite.com;
root /home/forge/mysite.com/dist/;
ssl_certificate /etc/nginx/ssl/mysite.com/370952/server.crt;
ssl_certificate_key /etc/nginx/ssl/mysite.com/370952/server.key;
ssl_protocols TLSv1.2;
ssl_ciphers ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384;
ssl_prefer_server_ciphers on;
ssl_dhparam /etc/nginx/dhparams.pem;
index index.html index.htm;
charset utf-8;
try_files $uri $uri/ /index.html;
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log off;
error_log /var/log/nginx/mysite.com-error.log error;
location ~ /\.(?!well-known).* {
deny all;
}
}
然后我构建它的过程是:
cd /home/forge/mysite.com/
npm install
ng build --prod --aot
我配置我的mysite.com指向IP,在DNS方面,这里没有问题。
当我检查日志时,我有:
2018/06/27 03:00:11 [error] 20122#20122: *8 directory index of "/home/forge/mysite.com/" is forbidden, client: 109.7.226.209, server: mysite.com, request: "GET / HTTP/2.0", host: "mysite.com"
2018/06/27 03:12:09 [error] 24560#24560: *25 directory index of "/home/forge/mysite.com/" is forbidden, client: 109.7.226.209, server: mysite.com, request: "GET / HTTP/2.0", host: "mysite.com"
但我永远不会摆脱我的禁忌错误......
任何想法???
在构建之后,您将拥有一个dist文件夹,其中将有您的项目构建。 如果您的项目文件夹名称是mysite,那么您的nginx配置中的根路径应该是/home/forge/mysite.com/dist/my-site
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name mysite.com;
root /home/forge/mysite.com/dist/mysite;
...
....
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.