How to fix my amazon Ec-2 ip address - rest

server running on Amazon Ec-2. The web-server acts as back end for my application. My application does a Rest call on the web-server to send or retrieve data.
I want to fix the web-server ip so that even if my web-server crashes or I restart the server I don't need to change the REST call of my application since the address will change in amazon.
My application is a mobile application, is there any way in which I can achieve this so that i can make my mobile application independent from back end .
I know there is something called Elastic Ip but I don't know what it is and how to use it.
thanks in advance.

Elastic IP provides an option to reserve IP address and assign it to your instance. This way you can always have the same IP and it is a right option for you. This article discusses some approaches on how to use them.
Also, it is free when you assign it to running instance, but you will have to pay for it monthly if you don't use it.
Update
The simple way to associate elastic IP with you instance is via console.
First allocate your address in Elastic IPs section of console
Then start your instance
Go back to Elastic IPs section, select address and click Associate Address. Then choose your running instance.

Related

Hosting a website using server software

How can i host a website through my computer using server softwares?
I tried to host a website through my own computer using apache tomcat server but it didnt work ( please briefly explain every point )
The main issue that you need to deal with is getting the clients to your computer.
Yes, it is possible and yes I have done it, albeit a while ago.
You need to see if you can browse to your computers website from another device on your network, this will ensure that apache is working. Try another computer/laptop/tablet/whatever to see if this site reachable by other computers using the IP Address and possibly port number. If you cannot get to the site, there are settings in apache to deny certain ip's, google it to get the exact steps for your version. If it works, move on to step 2.
You will need a static IP Address to ensure that all further steps stay working, google this if you are not sure how to do it
You need to have the external IP address of your router(whatsmyip.org) or use Dynamic DNS to route traffic from an address to your ip and there are services that allow this. I can recommend no-ip.com - This is all assuming that you have access to the router.
You would be required to set up port forwarding on your router. This will direct the internet traffic to your computer. You will need to get the exact instructions for your specific model of router.
Please be aware that you need to have proper firewalls and systems in place to prevent attacks. I am sure that you are just testing at this point though...
All the best!

Is it possible to expose an Owin service?

We have created self-hosted services using OWIN. They are working fine inside the server and we can request and retrieve information using the http://localhost. We use a different port for each service so that we can go and get certain information from http://localhost:8001, other from http://localhost:8015 and so on.
Now, we need to expose the results of one of those self-hosted services to access to it through internet. We'd like to provide a custom address such http://ourpublicinfo.mydomain.com:8001 or using the server ip such http://209.111.145.73:8001.
Is that possible?
How can we implement it?
Our server OS is Windows Server 2012 R2
OWIN Self-Hosted apps can run on a Windows Service, as a Console process and, with if desired, as part of a more robust Host like IIS.
Since you mention your app is running as a service you're probably missing all the GUI goodies IIS provides. In reality however, IIS works on top of http.sys, just as HttpListener does (which is probably what you're using to self-host your app) 1. You just need to do some manual set up yourself:
First of all, you need to make a URL reservation in order to publish on a nonstandard port.
Why would you do that? Quite simply because you're not running under localhost alone anymore on your very own local machine, where you probably are an admin and/or have special privileges/powers.
Since this is a server, and the user used for running the Service might not be an admin (most probably), then you need to give permission to that user to use that URL... and here is where URL reservations come into scene.
You pretty much have to options:
open up the URL to be used by any user:
netsh http add urlacl url=http://209.111.145.73:8001/ user="everyone" listen=yes
or open up the URL to be used by the user(s) running the service, e.g.: NETWORK SERVICE:
netsh http add urlacl url=http://209.111.145.73:8001/ user="NETWORK SERVICE" listen=yes
There is a way to make the reservation for several users too, using sddl, user groups, etc... but I'll not get into it (you can look that up).
Second of all, you need to open up a hall through your firewall (if you don't have one on this day and age, I pity you!)
There are plenty of tutorials on this. You can use a GUI, netsh.exe and what not.
Pretty much all you need to do is make sure you allow incoming connections through that port and that should do the trick.
To make sure the hall is open through and through you can use a tool like http://www.yougetsignal.com/tools/open-ports/ and insert 209.111.145.73 in the Remote Address and 8001 in the Port Number.
If for some reason it shows that the port is closed, even after creating an incoming rule in your firewall for it, then you probably have one or more firewalls in between your server and the outside world.
With those to elements in place you should be able to access your Self-Hosted Service from the outside.
As for accessing your service through an address like http://ourpublicinfo.mydomain.com:8001, you'll need to create a DNS entry somewhere, most likely on your Domain Registrar for mydomain.com, where you could create an A Record for your ourpublicinfo subdomain pointing to 209.111.145.73.
From this point on, you should be able to access your service through direct IP and Port or through the afore mentioned URL.
Best of luck!
Note:
If your service will be access from other domains, you might need to make sure you have CORS (Cross Origen Resourece Sharing) well defined and working on your service too ;)

Can I force Eureka registrations to use an ip address instead of a hostname?

I have a standalone, embedded Eureka server powered by Spring Boot 1.2.0.RELEASE and Spring Cloud 1.0.0.RC1. I see services properly registering themselves in the dashboard, which is great. The status links are using the host name of the box they are running on. Unfortunately, we are using virtual machines and they don't register themselves in DNS, which means that the links are unresolvable. I started looking through the code but was unable to find a way to force the links to use the host's ip address instead. Having a broken dashboard is not the end of the world but I am afraid that once we start using Ribbon or Feign to contact services, those URLs will also use the host name and be unresolvable. Maybe what I am really asking is there a way to force the clients to register with an ip address instead of a host name? Any help is appreciated.
set eureka.instance.preferIpAddress=true as documented here

How to make a Google Cloud SQL Instance accessible for any IP address?

I have just created a Google Cloud SQL instance. When I was looking on the access control of my instance, I found that if I want to access my database, I should authorize my IP address to get the right to access the database, but the problem is that my application will be deployed anywhere where the clients need, and even if I know where they will run the application and also I authorized their IP address, it (the IP) will be changed at least one time every 24 hours because it is not static IP, and then I have to re-authorize the IP again and again!
Is there any way to make the instance accessible from any IP?
Thanks
You can whitelist any subnet. You just need to enter it using CIDR notation: http://en.wikipedia.org/wiki/Cidr
In particular, you can whitelist 0.0.0.0/0 which includes all possible IP Address.
Please note that this is not recommended for security reasons. You want your access to be as restricted as possible.
This is an older post, but I noticed it on the sidebar so I figured I would add my 2c.
If you're able to use Cloud SQL Second Gen (currently in Beta) there is a new feature which allows access to the database without having to whitelist any firewalls: https://cloud.google.com/sql/docs/sql-proxy
Today, I was looking for a way to set-up an MS-SQL server for development purpose and found the similiar problem (how to allow my laptop to access).
This guide, helps.
In short, you need to allow firewall to enable EXTERNAL access to your VM instance at port 1433.

Set up local development environment for heroku facebook app

I have my app up in canvas but am at somewhat of a loss as to how I can test locally. I'm building my app on top of nodeJs to give it a try. I have a dev app that hasn't been deployed to heroku so I'm all set there, save some details to follow. I know my computers IP address but I'm not sure if that's the one I need. How do I find the correct IP. Something like: 0.0.0.124:5000 is the example that's given. To summarize what I need to know:
A) how to find the correct local IP
B) how and where to configure apache server (I have the code from heroku just need to know what file it goes into and where to find it).
C) How to export port 80
D) find out if I need access to my local dsl router admin area to set static ip or use dynamic one
Thanks in advance
From the Heroku documentation:
https://devcenter.heroku.com/articles/facebook#1-creating-a-development-facebook-app
Do you need the IP address for a callback URL? If so, I recommend signing up with a dynamic DNS service so your home Internet connection has a consistent domain name even if your home IP address changes.
You'll also need to forward the appropriate port from your home router to your development machine.