【问题标题】:nginx - Setup HTTPS Rest API on AWS EC2 Instancenginx - 在 AWS EC2 实例上设置 HTTPS Rest API
【发布时间】:2019-07-08 00:55:36
【问题描述】:

在带有 Ubuntu 18 的 AWS EC2 实例上,我正在运行一个提供 REST API 的快速服务器。我正在尝试使用 HTTPS 保护服务器,因为使用 API 的网站有一个 .app 域,因此网站访问的任何内容也必须使用 HTTPS。否则,我会收到“混合内容”错误。

我正在关注this 指南,该指南使用 Nginx 和 Let's Encrypt 使用 HTTPS 为注册域上的网站提供服务。有一次,该指南说将以下内容添加到我的 nginx 配置文件中,其中“example.com”和“www.example.com”应该替换为我的实际域名。

server {
   listen       80 default_server;
   listen       [::]:80 default_server;
   server_name  example.com www.example.com;
   root         /usr/share/nginx/html;
   location / {
      proxy_pass http://127.0.0.1:3000;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection 'upgrade';
      proxy_set_header Host $host;
      proxy_cache_bypass $http_upgrade;
   }
}

但是,我并没有从我的服务器提供网站(实际网站托管在 Github 页面上)——我只是提供 API,如下所示:http://ec2-my-ip-address.compute-1.amazonaws.com/api_endpoint

我是否仍将“example.com”替换为我网站的域名,还是将其替换为 ec2-my-ip-address.compute-1.amazonaws.com/api_endpoint

此外,我可以删除 root 设置,因为我没有提供任何 HTML 页面吗?

【问题讨论】:

    标签: amazon-web-services express nginx https


    【解决方案1】:

    似乎不可能获得 AWS 域名的 Let's Encrypt 证书,因为他们明确将 AWS 列入黑名单:https://community.letsencrypt.org/t/policy-forbids-issuing-for-name-on-amazon-ec2-domain/12692/4

    我们特别列出了 amazonaws 域,因为我们知道它们是短暂的。我们今天可能会证明一个属于您,然后明天可能属于其他人。

    【讨论】:

      最近更新 更多