Google API Web Client Oauth 2 redirect uri for aws ec2 uri - amazon-ec2

I have developed a google analytics management app using google API's and oauth2. I could add localhots:8001 successfully in redirect URI.
Now I have deployed my app in aws ec2 instance. I need to add my aws ec2 instance domain name as redirect uri. It is not taking my ec2 domain name. It says domain must be added in authorized domain list.
I would need to know what are the basic steps to figure out such situations.

The only way to add a redirect uri is if you own the domain. Then you can point the domain to to your server (ec2 address).
If you already own the domain, then see the process for pointing the domain to a server in your domain registrar.
Then use that url for redirect after auth.

Related

SSL in EC2 without ELB

I am running a Spring Boot application in EC2. I want to make the API calls as HTTPS instead of HTTP.
This is what I did:
Brought a domain in godaddy and configured it in Route 53.
Created a cert from AWS certificate manager.
Created a Load Balancer and added the cert.
In route 53 directed my traffic to ELB.
Above things are working fine now. I have only one instance. Use of ELB is only for SSL. But I want to get rid of ELB as it is costing me more
Is there any other way I can make the API calls as HTTPS for spring boot application running on ec2 without ELB?
ELB can be quite expensive, and most of all useless if you have only one instance.
Try to put CloudFront in....well...front of your instance. You get the benefit of managing AWS certificates in the same way you are doing with the LB, and also you can take advantage of caching and edge locations.
You can also redirect Route53 to CloudFront, just add a CNAME to your hosted zone that reference the cloud front DNS.

AWS API Gateway Pointing to DigitalOcean Domain

There is requirement we need to create a new AWS API Gateway but our Domain resits in the Digitalocean, So can we point the API gateway endpoint to the digitalocean domain. So the traffic should come to the domain and then API gateway.
Yes you can do that, you have to
Request certificate
Approve certificate (To prove your ownership of domain)
Create custom domain for API Gateway
Add base-path mapping (Attach to respective API endpoint)
Please follow below detailed link
https://medium.com/#maciejtreder/custom-domain-in-aws-api-gateway-a2b7feaf9c74

Wix Domain Route to AWS Instance

I have a domain at my WIX Account. I have an AWS EC2 Instance. For URL Masking, I approched this URL link: https://www.youtube.com/watch?v=tZh7sqs1YFo.
Therefore, I created a Hosted Zone in AWS Route53 as it says. I added A Record Set and CNAME Record Set. I changed domain Host points to in the Wix to the AWS EC2 Instance Public IP Address.
Wix Domain Host
Then when I wanted to change the Name Servers in the Wix, it said to not editable fields in the Name Servers.
Name Servers are not editable
So domain is working without the www. If I use www, it stays to the user on the WIX site otherwise it forwards to the AWS EC2 Instance site but I want to use www so I changed CName to my WIX Domain CNAME.
WIX CNAME
But www is not working for my AWS EC2 Instance, it stays the old one WIX Site URL and when I try to reach without www, it takes to the user on the AWS EC2 Site.
I want to know whether I am going to right way or if I am wrong please correct me in this problem.
Can you explain the problem you are trying to solve?
If you are trying to obscure web pages and create a proxy model then the best way to accomplish this it to use the wix-router capability.

No 'Access-Control-Allow-Origin' issue, despite all resources being on same domain

I am writing a javascript/strophejs xmpp client, and have been so far using it to connect to a xmpp server hosted at hosted.im, via a public BOSH service (http://bosh.metajack.im:5280/xmpp-httpbind). The html/javascript is also hosted online, at testserver.host56.com (not the real url).
Now, I decided to host the xmpp server on the amazon web cloud, and use my own Bosh service, hosted on this server as well.
Now, my ec2 instance is at myAWSDNS.us-west-2.compute.amazonaws.com (also not real url).
I also have a BOSH service up and running, at myAWSDNS.us-west-2.compute.amazonaws.com:7070.
Finally, I have also allowed traffic to this ec2 instance through both the instances firewall and through the AWS Security Group policy.
However, when trying to connect to this instance's xmpp server (openfire), using my JS/strophejs client, I get the following message in the Chrome javascript console:
XMLHttpRequest cannot load http://myAWSDNS.us-west-2.compute.amazonaws.com:7070/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://myAWSDNS.us-west-2.compute.amazonaws.com' is therefore not allowed access
Why am I getting this issue, if the origin is on the same domain as the requested resource?
The Ec2 instance is running Windows Server 2012.
This is the code I use to log in:
var conn = new Strophe.Connection("http://myAWSDNS.us-west-2.compute.amazonaws.com:7070/");
conn.connect("chris#myAWSDNS.us-west-2.compute.amazonaws.com", "myPassword", somecallback);
Thanks,
best regards,
Chris
As previously mentioned, even if you're on the same domain, the ports must also match otherwise CORS is required.
You may not be using the correct URL for your connection manager, all of the ones I've seen use an address ending in /http-bind/ or similar.
Have you tried connecting with Strophe.Connection("http://myAWSDNS.us-west-2.compute.amazonaws.com:7070/http-bind/");?
Also, you can test for the presence of the crossdomain.xml file by simply visiting http://myAWSDNS.us-west-2.compute.amazonaws.com:7070/crossdomain.xml to ensure that CORS has been successfully enabled.
The browser will not allow since the ports are different. I don't know what you have at AWS, but you can proxy the request in both direction, like as:
http://myAWSDNS.us-west-2.compute.amazonaws.com/http-bind/ <---------> http://myAWSDNS.us-west-2.compute.amazonaws.com:7070/
See item no 5: Connecting with Strophe.js of the tutorial for Apache use case.

amazon S3 database options and using EC2 as a REST api from S3

I am hosting my website on S3.
On my local host I am using backboneJS above a PHP Rest API that uses mySQL as a database.
So i opened an EC2 to host my Rest API but then realized this means cross domain AJAX.
How can i use EC2 as a Rest API if my index.html sits on S3?
What are my other DB options for S3?
many thanks,
Your JavaScript is being executed on web pages served from S3, and it has to access a REST API from a server you run on EC2. Unless the web pages and server are in the same domain (say, example.com), this will be a cross-origin request, prohibited by browsers by default.
Solution 1: have your S3 pages and your EC2 server in the same domain. S3 allows static website hosting that makes your S3 objects (web pages) available at the address of your choice. Put them and your EC2 server at addresses on the same domain, and it can work.
Solution 2: have your REST API server allow cross-origin requests. Since you control this EC2 server you can modify it to tell web browsers to allow pages from other domains to make such requests to your server. This involves setting several headers on your responses, and usually requires your server to respond to HTTP OPTIONS requests properly, too. See the CORS specification to get started on that.
You also ask about other DB options. If you keep your own EC2 server to provide the REST API it can use pretty much any kind of database you like, either running on the same or other EC2 instances, or database-as-a-service offerings like AWS RDB or AWS DynamoDB. But if you want to connect to the database directly from your web pages' JavaScript you would have to use a service that provides an HTTP API directly and that supports CORS. RDB does not provide an HTTP API at all, and DynamoDB does not seem to support CORS at this time, so neither of them would work.

Resources