Use Godaddy Domain name Instead of Default Elastic BeanStalk URL

寵の児 提交于 2020-04-18 03:51:08

问题


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.

I have an API hosted on EB and the Squarespace site makes requests to that 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

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

EDIT -

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. 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();
            });
        }
    }

回答1:


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



来源:https://stackoverflow.com/questions/60860216/use-godaddy-domain-name-instead-of-default-elastic-beanstalk-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!