Access publicly accessible service on host from Dokku guest - networking

We are converting to Dokku, and as a part of this process the database (PostgreSQL) will remain running directly on the host for the time being.
The database is used by serveral servers spread around the Internet and accessible using its public IP.
I can psql to it from any server, including the server where it's hosted.
However, from inside the Dokku guest running on the same server I get timeout. It would appear somewhere access to it is being blocked.
Any thoughts on why this is happening?

Related

How to send requests to a web server running inside a docker container inside an AWS EC2 machine from the outside world?

I have a Python Flask web server running inside a docker container that is running in an AWS EC2 Ubuntu machine. The container is running on a default network setting (docker0). Within the host EC2, I can send requests (Get, Post) to this web server using docker-machine ip (172.x.x.x) and the forwarded ports (3000: 3000) of the host.
url: http:// 172.x.x.x:3000 / <api address>
How can I send requests (GET, POST) to this web server from the outside world? For example from another web server running in another EC2 machine. Or even from the web using my web browser?
Do I need to get a public IP Address for my docker host?
Is there is another way to interact with such web server within another web server running in another EC2?
If you have a solution please explain with as many details as you can for me to understand it.
The only way that I can think of is to write a web server on the main EC2 that listens to the requests and forward them to the appropriate docker container webservers?! But that would be too many redundant codes and I would rather just request to the web server running on the container directly!
The IP address of the docker is not public. Your EC2 instance usually has a public IP address though. You need an agent listening on a port on your EC2 instance and pass it to your docker/Flask server. Then you would be able to call it from outside using ec2-instance-ip:agent-port.
It's still not a long-term solution as EC2 IPs change when they are stopped. You'd better use a load-balancer or an elastic IP if you want the ip/port to be reliable.
That's right, it makes a lot of redundant code and an extra failure point. That's why it's better to use Amazon's managed docker service (https://aws.amazon.com/ecs/). This way you just launch an EC2 instance which is a docker and has a public IP address. It still allows you to SSH into your EC2 instance and change stuff.

how to restart a web after re-starting a deallocated Azure Windows VM

I deallocated my Azure Windows server VM last year to save money.
Just re-allocated and restarted it.
Can log in OK.
But when I try to browse my web hosted by the VM, from public Internet I get:
"This page can’t be displayed"
How do I re-start my .NET web? (VisualBasic web app)
As I known, if you shut down/stop your VM by Azure Portal, then the IP (public and internal IPs) addresses that were assigned to your Azure VM would be released as follows:
Virtual machines (classic)
Virtual machines
As this blog mentioned that:
Note that the IP addresses were excluded (internal and public), if you do not book a public IP (maximum of 5 per signature), you may notice that you have a web site or application on this machine, the web site / application will be unavailable and when turning it back as a new public IP will be provisioned. You have to do a DNS entry manually if you are accessing by a proper name.
I have tried to restart my VMs and wait for a while, then I could access my default website. Additionally, you could try to remote to your VM and check your app. Also, please try to check your inbound network traffic.

Derby Database Access thorugh a local network LAN

I created a java desktop application with derby client driver using netbeans 8.1.
I used this code to get connected to the database.
Class.forName("org.apache.derby.jdbc.ClientDriver");
Connection conn = DriverManager.getConnection("jdbc:derby://localhost:1527/LibertySchool;create=true;user=liberty;password=liberty");
conn.setSchema("LIBERTY");
Statement s = conn.createStatement();
s.executeQuery("SELECT * FROM USUARIOS");
ResultSet rs = s.getResultSet();
if (rs.next()) {
Login entrar = new Login();
entrar.setVisible(true);
}
The standalone application is working normal on the pc that it was created on after build the dist file has the app.jar file and everything works normal.
I created this so few client computers can access the same application to update data. I have started the derby network on client machine, I have also change the connection from localhost to use the app database location ip server.
But my app does not work on clients on the same network only on the computer where it was built. Other applications that do not use databases works well over the network, it seems that derby database folder has to be moved also to the client machine.
I need to know how to set the client machine properly so users can access the app with the database.
Can someone please give some hints.
If you want to make a client-server connection with the client on a different machine than the server, you'll have to do several things:
Change localhost to a valid externally visible address for the server machine. You can use an IP address, or a host name, e.g., 192.168.1.104:1527 or Carlos-Mac-Pro.att.net:1527, but you're going to need to figure out the right network address to use. localhost:1527 will only work when the client and server are on the same machine.
Ensure that your network allows connections between the client machines and the server machine. Nowadays, most machines will, by default, prevent most inbound network connections from other machines, as a security measure, so you'll need to configure the server machine's firewall, as well as any network devices that are being used in your local network between the client machines and the server machine, to allow TCP/IP connections on port 1527.
I don't think you want to move the derby database folder to the client machines. That would be a completely different architecture for your application (embedded vs client-server). Here's some good background material about the differences between the two configurations: https://db.apache.org/derby/docs/10.13/getstart/cgsquck70629.html

Get Client Host name on Azure ASP App

Trying to get the local machine name for an Azure hosted ASP application.
Request.ServerVariables["HOST_NAME"]
returns 127.0.0.1 as does HOST_ADDRESS
In fact I can't find anything in Request.Server variables that reflects the local hostname.
Dns.GetHostEntry(Request.UserHostAddress).HostName
will not work as this is a server side lookup, so all you get is the public gateway name not the actual end-user machine name.
Any ideas?
I am stumped and just feel this should be so simple!??!
As you're potentially behind a load balancer when you deploy to azure try using
Request.ServerVariables["REMOTE_ADDR"]

azure connect between azure myWebRole and nonazure server not working

My webapplication hosted on windows azure, needs to communicate with TFS Server. When any one login to my web app using live id, I want the logged in user to use my Team foundation server(TFS) credentials -username,password and domain to programatically authenticate and connect to our TFS server and create some work items.
I configured my azure connect for the communication to happen between azure WebRole and TFS server (our TFS is non-azure ).I added both the WebRole and the TFS Server into single Connection Group
In my azureportal ,I can see mywebrole and my TFSServer as connected the machine endpoint is active, and that it refreshes since the last connected updates
.But when I try to run my web application from azure and when it tries to communicate with our TFS server ,its throwing error message saying Error message : Team Foundation services are not available from server eg.,http://xyz-abcxyx-01:8080/tfs/eas/. Technical information (for administrator): The remote name could not be resolved: 'xyz-abcxyx-01'
Any suggestions to resolve this issue ?
You should enable remote desktop on your WebRole and connect to one of your instances. Then, try to ping the IP of your TFS server (not the hostname xyz-abcxyx-01). Maybe this is simply a DNS issue (even though using hostnames works with Windows Azure Connect).
If pinging the IP works, but pinging the hostname doesn't work you have a few options left:
Use the IP instead of the hostname. This won't work if you configured your TFS to use host headers.
Create an elevated startup task to modify the hosts file and map the IP to the hostname. In your code you can keep working with the hostname.
Try to modify the DNS server configured in your WebRole to use the default DNS server + your internal DNS server. But to me this doesn't look like a clean solution.
Anyways, in each solution you'll want to store the IP/hostname in the ServiceConfiguration and make sure your code supports changes to the ServiceConfiguration. This will allow you to change the IP/hostname without having to redeploy.
You should check if TFS server is listening on all network interfaces, include the one created by Azure Connect (start with 2a01). Next try to connect to TFS from a machine on the local LAN, just to make sure it is configured correctly. You don't need to use IP for referring to TFS, DNS name is definitely supported out of box.

Resources