Accessing Public Page from AWS Ubuntu server - apache

I am new to Amazon Web service. I created an Ubuntu 16 instance with AWS. Installed Apache and restarted the service. But still I am unable to figure out how to access the start page from a browser. Which IP address should I use? Public ip or elastic ip? Also do I need to change any configuration file? Thanks.

You need to use the public IP address, depending on your usecase you can even use an elastic IP address.
However you need to configure your security groups in order to access the web page.
Go to your security groups
Select the relevant security group
Add inbound rule to port 80 (TCP)
Then you will be able to access the page. Please refer this guide for more information.

You can use public ip / public DNS. These both will change upon restart of an instance. Elastic IP is useful when you want your IP address to be persistent. e.g. To make an entry in your domain DNS records.
Make sure your default site is pointing to correct directory as you are going to access using IP address.
If your instance is in VPC then it must be in public subnet. (subnet with Internet Gateway route attached)

Related

Static Webpage hosted in a EC2 instance

I followed cloud guru's course to create a ec2 instance in aws. I installed apache webserver and created a static page. When I login to the ec2 instance and run the curl command (from within ec2 instance) using "Public DNS (IPv4)" address , I am able to view the page in browser. However when I try to open it in my browser, I am unable to view. I did not make any changes to outbound rules in my security group.
I am unable to access the page using the public ipv4 ipaddress both from within ec2 and outside.
I can't comment due to new user. This seems "security group" inbound rule issues. Did you open port 80 in security group "inbound"?
When you use "public IP" even from EC2 box, that will be considered as traffic from internet and if your security group is not configured to accept (inbound) traffic from internet, you can't access the website available on port.
NOTE: Suggest to open port to "MyIP" instead of "whole world".

Apache2 server inaccessible from outside

I have a LAMP(ubuntu-16.04, PHP) setup and while using it I am able to access it from home network, (phones, etc.) but for others it says that the site can't be reached. I go to my page via my IP and have no problem reaching it. Are there any steps that I can do? I have tried running node.js as well and i have the same problem there.
There is probably a firewall between your home and the Internet. A firewall prevents connections from the Internet. In fact, some one else, in another home, might have a computer with the same IPv4 address as you have. To make your web server public, you need a public IP address (globally allocated uniquely to you) and you need to route that address to your webserver.
Use a webserver proxy service such as PageKite.
Alternatively method:
Your router most likely already has a public IPv4 address. On http://192.168.1.1 or http://192.168.1.254 or a comparable administration page (usually accessible using the user admin with the password admin, or with a user with the same name as your ISP and that same name as password) you can configure your server as a public web server.

What will be the DNS name for Virtual Machine instance created in IBM Bluemix?

I have created a Virtual Machine in Bluemix. I have installed NGINX web server on it. To access the web application that is deployed on NGINX, should I use a public IP address (for e.g. http://123.456.78.9) or is there a domain name associated with the instance (something like http://abcxyz.bluemix.net)?
When you launch any VM in cloud by default they should be not accessible from public internet unless you attach a public ip address to them.
Once you have attached a public ip address to your instance and configured the firewalls to allow incoming connections (http, ssh etc) you can update your DNS server to redirect traffic there.
AWS create a public FQDN at the time of launching the ec2 instances as
ec2-nn-nn-nn-nn-region-compute.com (where nn are ip address bits), not sure any similar thing with bluemix but it is less likely to have abcxyz.bluemix.

How to configure Apache WebServer to be accessed by public domain (or static IP) I have?

I am trying to setup a web-server at home on PC.
I have an Static IP address (say 1.2.3.4 or Domain XYZ[dot]com), which I have configured on my router.
When I try to access, XYZ[dot]com or "1.2.3.4", it opens my routers login page.
On the other hand, Apache Server, installed on the PC, works fine. when I write localhost/index.html or 127.0.0.1/index.html - it opens that page.
QUESTION
How can I link the Public IP address to the Apache Server (or the website hosted on localhost on my PC)?
EXPECTED SOLUTION
If anyone visits "http://XYZ[dot]com", the website hosted on my PC is opened on his/her web browser.
The router's login page is usually accessed via a private IP. The router's admin interface shouldn't be made available to the Public Internet.
What you need to do is:
find out what your router's public IP is (you can use http://whatismyipaddress.com/)
setup port forwarding on your router. You want connections made to the routers public IP to be forwarded to your PC. Ex: Your router's public IP is 21.21.21.21 and your PC's private IP is 192.168.0.100. You need to configure a rule which says that any connection made to to 21.21.21.21:80 needs to be forwarded to 192.168.0.100:80
As for the http://XYZ[dot]com part you need to setup that domain pointing to your public IP with a com. DNS registrar and configure an apache virtual host for that domain (http://httpd.apache.org/docs/2.2/vhosts/)
If you have static IP ADDRESS then you don't need to do anything extra you just have to add apache exception in firewall then tick the checkbox under private and public column and you are done. then anyone can access your website all over the world.
You will need to create a permission for that port on your firewall and configure the ports on your router. Keep in mind that most internet providers have business and residential plans. In residential plans it is common for them to block access to ports 443 and 80 externally (enabling your router will not change that because the requests will not even arrive on it).
An excellent step by step for those who use linux and also want to set up a domain name

How can I make Apache on an amazon ec2 linux box using the elastic IP instead of the private IP?

I've migrated a website to Amazon ec2 that hooks into a service we are using that is installed on another server (not on Amazon). Access to the API for that service is IP-restricted and done by sending XML data using *http_build_query* & *stream_context_create* in PHP.
If I want to connect to the service from a new server, I need to ask the vendor to add the new IP first. I did that by sending the Elastic IP to them, but it doesn't work.
While trying to debug, I noticed that the output for $_SERVER['SERVER_ADDR'] is the private IP of the ec2 instance.
I assume that the server on the other side is receiving the same data, so it tries to authenticate the private IP.
I've asked the vendor to allow access from the private IP as well – it's not implemented yet, so I'm not sure if that solves the problem, but as far as I understand the way their API works, it will then try to parse data back to the IP it was contacted from, which shouldn't be possible because the server is outside the Amazon cloud.
I might miss something really obvious here. I added a command to rc.local (running CENT OS on my ec2 instance) that associates the elastic IP to the server upon startup by using ec2-associate-address, and this seemed to help make a MySQL connection to another outside server working, but no luck with the above mentioned API.
To rule out one thing - the API is accessed through HTTPS, with ports 80 and 443 (and a mysql port) enabled in security groups and tested. The domain and SSL are running fine.
Any hint highly appreciated - I searched a lot already, but couldn't find anything useful so far.
It sounds like both IPs (private and elastic) are active in your VM. Check by running ifconfig -a. If that's what's happening then the IP that gets used for external traffic will depend on the remote address and your VM's routing table. It could even vary from one connection to the next.
If that's what's going on then the quickest fix would be to ifconfig down the interface that has the private address. That should leave only the elastic address for all external connections. If that resolves the problem then you can script something that downs the private IP automatically after the elastic IP has been made active, or if the elastic IP will be permanently assigned to this VM and you really don't need the private IP then you can permanently disassociate the private IP from this VM.