使用Godaddy域名代替默认的Elastic BeanStalk URL [英] Use Godaddy Domain name Instead of Default Elastic BeanStalk URL

查看:105
本文介绍了使用Godaddy域名代替默认的Elastic BeanStalk URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Godaddy上购买了一个域名.该网站托管在Squarespace上,因此我不想将请求从 https://example.com 转发到Elastic Bean Stalk上的站点.

I have a domain name bought on Godaddy. The site is hosted on Squarespace, so I don't want to forward requests from https://example.com to a site on Elastic Bean Stalk.

我在EB上托管了一个API,Squarespace网站向该API发出了请求.

I have an API hosted on EB and the Squarespace site makes requests to that API.

我需要做的是更改默认的EB URL https://dataservice-env.example.us-east-2.elasticbeanstalk.com https://example.com/api

What I need to do is change the default EB URL https://dataservice-env.example.us-east-2.elasticbeanstalk.com to https://example.com/api

我在这里几乎是DNS菜鸟.我已经找到了将Godaddy域转发到EB的文章,但这不是我想要做的,这就是我所描述的...

I'm pretty much a DNS noob here. I've found articles to forward godaddy domains to EB, but thats not what I want to do, which is what I think this is describing...

https://stackoverflow.com/a/38225802

编辑-

如果有人尝试做类似的事情(通过一个子域上的HTTPS从一个域向EB发送API请求),这就是我的方法....

If any one else is trying to do something similar (make API requests from one domain to EB over HTTPS on a subdomain) here's how I did it....

  1. 在Route 53中注册域
  2. 创建托管区域
  3. 从GoDaddy导出的区域文件
  4. 将区域文件导入到Route 53托管区域
  5. 从AWS Certificate Manager请求证书
  6. 使用子域api.example.com作为域名值
  7. 点击在Route 53中创建记录"
  8. 在Route 53中,点击创建记录"
  9. 名称:api.css-llc.io
  10. 类型:A-IPv4地址
  11. 别名:是
  12. 别名:EB URL-env.tstuff.us-east-2.elasticbeanstalk.com
  13. 创建负载均衡器.最重要的是为创建一个监听器 HTTPS这会将请求从端口443转发到端口80,即.net 核心API在端口80上运行
  14. 侦听器端口:443
  15. 实例端口:80
  16. 侦听器协议:HTTPS
  17. 实例协议:HTTP
  18. 使用上面创建的api.example.com证书
  19. 将此负载均衡器添加到EC2实例. EC2实例应为 在部署Docker映像时创建.允许HTTPS入站流量 负载均衡器创建的两个安全组上
  20. 将CORS支持添加到API Server. .net Core CORS的以下示例
    这应该返回正确的响应头,并且应该能够 通过HTTPS从example.com向api.example.com发出请求
  1. Register a domain in Route 53
  2. Create a Hosted Zone
  3. Exported zone file from GoDaddy
  4. Import Zone File to Route 53 Hosted Zone
  5. Request a certificate from AWS Certificate Manager
  6. Use subdomain api.example.com for domain name value
  7. Click ‘Create Record in Route 53'
  8. In Route 53 click 'Create Record'
  9. Name: api.css-llc.io
  10. Type: A-IPv4 Address
  11. Alias: Yes
  12. Alias Target: EB URL - env.tstuff.us-east-2.elasticbeanstalk.com
  13. Create Load Balancer. Most important is to create a listener for HTTPS This will forward requests from port 443 to port 80, the .net Core API is running on port 80
  14. Listener Port: 443
  15. Instance Port: 80
  16. Listener Protocol: HTTPS
  17. Instance Protcol: HTTP
  18. Use api.example.com cert created above
  19. Add this load balancer to EC2 Instance. The EC2 instance should be created when deploying the Docker image. Allow HTTPS inbound traffic on the two security groups created by the load balancer
  20. Add CORS support to API Server. Example below for .net Core CORS
    This should return the correct response headers and should be able to make requests from example.com to api.example.com via HTTPS

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            app.UseCors(builder => builder
                .AllowAnyOrigin()
                .AllowAnyMethod()
                .AllowAnyHeader());

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
    }

推荐答案

所有这些都是由注册到错误域的SSL证书引起的. CORS发挥了应有的作用.

All this was caused by the SSL cert registered to the wrong domain. CORS is functioning as it should.

这篇关于使用Godaddy域名代替默认的Elastic BeanStalk URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆