在Amazon EC2上通过Nginx提供的Angular网站返回404

时间:2016-05-09 23:37:19

标签: angularjs nginx amazon-ec2

我正在尝试使用nginx在ec2实例上提供角度站点。

在我的/etc/nginx/nginx.conf文件中,我定义了一个服务器:

server {
    listen       8081;
    server_name  localhost;

    location / {
        root   html;
        index  index.html index.htm;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }
}

在http块中,我已经包含了配置文件的路径,如下所示:

include /home/bitnami/apps/mysite/mysite.conf;

路径正确,因为以下终端行在vim中打开文件:

sudo vim /home/bitnami/apps/mysite/mysite.conf;

当我去public.ip.address:8081时,会显示Nginx欢迎页面。当我去public.ip.address:9000应该是mysite时,我得到404错误。

其他信息:

  • 我正在'微小'的ec2实例上使用MEAN Bitnami图像。免费等级。
  • Nginx启动并重新加载
  • 我在端口8080,8081和9000上添加了安全组的入站规则。端口8080和端口8081工作,端口9000没有。
  • 完全相同的代码在我的本地计算机上运行,​​所以我认为它必须是某个地方的权限问题?

修改

  • 工作端口是8080和8081.端口8080现在是我的API。端口8081是Nginx欢迎页面。

**问题**

我的mysite.conf中的root是错误的。

server {
    listen 9000;
    root /Users/me/Repository/mysite/dist;

    access_log off;
    error_log off;

    index index.html;

    client_max_body_size 10m;

    location ^~ /api/ {
        proxy_pass http://localhost:8080/;
    }

    location = /nginxstatus {
        access_log off;
        return 200;
    }
}

0 个答案:

没有答案