How to Configure AWS for Reverse Proxy with NGINX? - amazon-route53

At a previous company I worked at, we had an NGINX server running as an AWS EC2 instance, with only a private IP address (10.x.x.x), that received inbound public traffic thanks to entries in Route 53. I'm trying to setup the same environment but I seem to be missing a critical piece of the puzzle!
We had a primary domain, then every sub-domain was proxied using NGINX. Every entry (can't remember whether A or CNAME records) pointed to the private IP of the NGINX server and back then (6/7 years ago) it worked. However, I didn't set it up and I don't know what else was involved.
To be clear, the NGINX server has no public IP address, yet it worked last time.
I seem to be unable to have Route 53 forward to a private IP address, but there must be a way to get this working using AWS, as it worked perfectly at my last company. Sadly, there's nobody there I can reach out to, so I'm asking here.
Can anyone assist, please?

Related

Aws ec2 and Route 53 domain

I'm banging my head against the wall at the moment.
What am I doing wrong here?
Your help would be much appreciated!
I started with AWS, bought a domain with route 53 and thought I could easily start using it.
Have made an A record with the server IP [static IP].
This seems to result in a DNS_PROBE_FINISHED_NXDOMAIN domain that can't be reached.
Even after waiting for hours.
Next solution I found on the web was setting a CNAME record;
This doesn't seem to work either.
What am I doing wrong here, any suggestions?
Thank you for your input
I have been learning a lot about AWS and it's quite handy.
[update]
* I found the dns name at the elastic IP settings [public DNS]
Step to do this :
Create A record of domain
Give same EC2 IP to A record
Change Security group of EC2 for port 80 and 443( if using) to all
Also try to ping EC2 IP by opening ssh port.
If do this all carefully. Then for IP changes sometime take times.
To see whether changes reflected or not.
Ubuntu :
open : /etc/hosts file and record for this.
terminal > sudo nano /etc/hosts/
add entry this file
xx.xxx.xxx.xxx www.xample.com
and save and close
then try to ping your domain and hit from browser. if this works then revert file changes. wait for Route53 to reflect changes in A record.
I found the problem.
When you register the domain, Amazon has set the nameservers, these nameservers on the register page and route53 were different. This is why I couldn't point the domain to my IP.
After setting them the same; the domain was pointing to my server.

Turning PC Into A Server

Sorry if I have this in the wrong community but I'm hoping one of you can help me out anyway.
I have a web hosting account with a UK company who I'm happy with, but I'd like to set up a little hosting account from my laptop, just to see if it's possible and easy enough to do really.
Trouble is I've been doing a lot of research online but coming up empty whenit comes to more of a "complete guide". Do any of you know of a good resource for setting up a home server for publishing "Live" websites with custom TLD domain names? I have a localhost server running and files hosted on there but I'm really looking for help with the IP and DNS parts for the custom domains.
For reference, I have a machine running Win7, Appserv 2.5.10, UK broadband and a .co.uk domain name registered with 123-reg.
Any help would be hugely appreciated.
You'll need to:
Point your domain to your laptop.
If you get static public IP address from your ISP, then you can just point the A record to this IP address.
Where do I set this A record? Almost all domain registrars give you a nameserver for free. You point your domain to their nameservers (generally ns1.somedomain.com and ns2.samedomain.com etc.). In the nameserver config, create a A (stands for authoritative) record and put in your static IP address.
What if my ISP doesn't give me an static IP address? This is where services like dyndns come into picture. They give you an agent that you'll install on your laptop, it detects the change in IP address and automatically updates the Nameservers accordingly. There are some free variants of dyndns as well if you don't want to spend money on this.
But my laptops IP address is something like 192.168.x.x and my site runs on localhost (127.0.0.1)? Your laptop is most likely NATed. Think about your public IP address to be that of your router. You will need to forward any connection coming to your router on port 80 or 443 to your laptop's (192.168.x.x) corresponding ports. This is called Port-Forwarding and all routers support this. Port-Forwarding is done by logging on to the admin interface of your router (Many times its at http://192.168.0.1 or http://192.168.1.1).
But again my application is accessible at localhost? You need to make sure your apache/nginx listens on 0.0.0.0 or atleast 192.168.x.x interface. This is how computers outside your laptop will be able to make connection to your laptop on port 80/443.

Redirecting a subdomain to AWS instance

I have a domain example.com that is being host on webfaction. However i would like to redirect its subdomain (e.g sub.example.com) to one of my AWS instance which has public DNS of:
https://ec2-xx-xxx-xxx-xxx.ap-southeast-1.compute.amazonaws.com:8083 (please note the port number).
This instance is then assigned with elastic IP address.
So far, the solution that i tried is:
Using CNAME redirection, however it does not work because of this: https://forums.aws.amazon.com/thread.jspa?threadID=55995
Then i proceed to use the old fashion .htaccess:
Redirect permanent / http://ec2-xx-xx-x-xxx.compute-1.amazonaws.com
order deny,allow
However, i want to keep the sub.example.com on the address bar instead of changing it AWS public dns.
Does anyone know what is the best way to solve this? Thanks
If you have assigned an elastic ip to the instance, you should be able to just setup a new 'A' record in your DNS that points directly to that IP address, no?
The listening on the specific port should be handled by the bindings on the instance (either thru apache or IIS)

Is it possible to see connection attempts to a Google Cloud SQL instance?

We are currently encountering the following error when trying to connect to a Cloud SQL instance: Lost connection to MySQL server at 'reading initial communication packet', system error: 0.
This is a familiar error, and as detailed here usually means the IP address needs to be whitelisted. However, we believe we have done so.
Is there a way to see connection attempts and their IP addresses that have been made (and refused) to the Cloud SQL instance?
Currently we don't expose that information but it is something we would like fix. :-)
According to #Razvan, as of September 2014, this information isn't exposed.
We ended up using CIDR blocks to search the space and find the actual IP address. This is unsatisfying, obviously, but it's a way to pin down the problem.
If other people want to sanity check that the problem is their IP is being refused, you can add 0.0.0.0/0 in order to accept all ranges and try to connect. If it works, you know what is the problem.
Be absolutely sure to remove this as an accepted range, after you are done, however!
Figured I might help someone who stumbles here.
Had exactly the same issue essentially trying to connect to a GCP SQL instance from a hosting provider.
Whitelist the IP address that is shown in my cpanel and it will not connect. (It used to, but the provider made some changes with their infrastructure lately and it stopped working)
put 0.0.0.0/0 in my Cloud Platform whitelist and it connects no problem.
So now I know that my cpanel IP is not the IP trying to connect to GCP.
After some hair pulling (figured that the bare metal server had a different IP than my cpanel IP, it did, but this also didn't work.)
finally tried the IP address for the name servers that point to my domain and bam. All is good.
If you are facing this issue, try your name server (usually something like NS1.hostingprovider.com etc..). I put both the NS1 and NS2 ip's in the whitelist and we are working fine.

Get Azure public IP address from deployed app

I'm implementing the PASV mode in a FTP server, and I send to the client the IP address and port of the data end point. This is stupid because the IP is actually where the client is already connecting, so there ire two options:
How could I get the public IP
address from a given instance? Not
the VIP, but the public one.
How could I get the original target
IP address that the user used from
a Socket object? Considering routers and load balancers in the middle :P
An answer to any of this questions would do, although there is another way that could work... may I get the public IP address doing a DNS look up of myapp.cloudapp.net?
A fourth option would be use the Azure Management API library... but, too much trouble :P.
Cheers.
Not sure if you ever figured this out, but here's my take on it. The individual role instances are all behind the Windows Azure load balancer and have no idea what the original, outward-facing IP address is. Also, there's no Management API call that returns IP address - Get Deployment returns the URL but not the IP address. I think the only option is going to be a dns lookup.
Having said that: I don't think you can host a passive ftp server in your role instance (at least not elegantly). You may open up to 25 input endpoints on your role (up from 5 - see my recent blog post about this update), but there's manual work involved in the configuration. I don't know if your ftp application lets you limit your port range to such a small number of ports. Also:
You'd have to define each port as its own input endpoint (this is the manual labor part I mentioned) - input endpoints don't allow a port range to be specified, unlike the internal endpoints.
You'd have to specify the port number that's used internally, and the port numbers would need to be sequential
One last thing on ftp: you should be able to host an sftp server with no trouble, since all traffic comes through one port.
The hack that I'm contemplating right now is to retrieve http://www.icanhazip.com/. It isn't elegant and is subject to the availability of that service, but it gets the job done. A better solution would be appreciated!