Openshift bind TCP port - python

I'm trying to deploy a python TCP listener on Openshift but I'm failing to understand how to manage external ports.
Googling and searching on Openshift's own KB, this article is mentioned lots of times but is no longer available. My TCP server app listens on port 8080 (as per $OPENSHIFT_PYTHON_PORT) and I'm trying to connect to it from the Internet on port 8000. Nevertheless, doing this means that a client app can establish a connection even if the server app is not started.
Does anyone have specific information on how to do this?

You can not make raw tcp connections to your OpenShift gears, you can only make http (80/443) and ws (8000/8443) connections. Both types of connections go through a proxy on the node, http goes through an apache proxy, and ws goes through a node proxy. If you want to make raw tcp connections you would have to use port forwarding from your location machine, and make sure that you are publishing the port information through a custom cartridge.

An Internet Archive grab of the removed KB article you mentioned says you could bind to internal ports 15000 to 35530. But this has now changed: my test OpenShift box didn't let me bind to any localhost port. Its $OPENSHIFT_PYTHON_PORT is accessible from the outside via normal Web ports (80 and 443; SSL decryption is done for you on 443). If you need other ports you probably need something other than Openshift.

Related

django nginx gunicorn config needs to work on ip:port

I have currently config nginx gunicorn everything is working fine i am building a rest api the django should work something like this ip:port but instead if i enter the IP address in the browser the django application is working there is no port used how to change it to run on a specified port.
your nginx use port 80 by default
Port 80 is the port number assigned to commonly used internet communication protocol, Hypertext Transfer Protocol (HTTP). It is the port from which a computer sends and receives Web client-based communication and messages from a Web server and is used to send and receive HTML pages or data.
You can run gunicorn specifying the port. In the example below 8000. And then point nginx to it.
gunicorn application_module --bind=0.0.0.0:8000

port is listening in server but unable to telnet ( Django with Apache )

I have developed a Django application which I wish to deploy on apache2.4 server. I have configured mod_wsgi and stuff on a system, which is going to be my server and localhost:8081 (apache's port) is working properly on the server system. I am in a corporate environment. When I wish to access the application from another system, I am unable to access the page.(The server and client are in the same network, both using LAN)
Observations:
8081 port is listening on my server system
(Proto: TCP, Local Address: 0.0.0.0:8081, Foreign Address: Computername:0, State: LISTENING)
I am unable to telnet to server ip on port 8081
(Connecting To 10.176.241.35...Could not open connection to the host, on port 8081: Connect failed)
Able to ping server IP (EDIT)
I have JDeveloper installed in my server system and I am able to access
the homepage of WebLogic server from another system though.
Site can't be reached, took too long to respond error while trying to
access the page from client system
What all I have done so far:
Followed the exact steps mentioned in here for configuring apache with django
Turned off firewall in both client and server systems
Add inbound and outbound exception rules in Advcanced firewall
settings in both client and server systems
I am unable to know the root cause of this problem and I have been working on this for a week and a half. I do not have much knowledge in networking and I am badly in need of some help. Sorry if the question is too naive.

How to make flask server running in a VM externally available?

If I run my flask app on my local machine I get proper results by connecting to http://127.0.0.1:5000/report?id=1
But now I want to make it externally visible by deploying my flask in a VM in azure. I have opened the port 80 on my VM. And I'm running the flask app using this:
if __name__ == '__main__':
app.run(host='0.0.0.0')
I'm still not able to connect to my flask server using this (assume the public IP address of my VM is x.x.x.x):
http://x.x.x.x:5000/report?id=1
Any suggestions how should I go ahead with it?
Edit: I'm able to psping my VM's public IP address on port 80.
The problem isn't related to Flask, since you opened up your application to listen on any public IP (0.0.0.0).
Moreover you should do a proper port mapping in your azure configuration. Google said, you might have a look here: https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-set-up-endpoints/
EDIT
Another idea, where some colleages often run into, is that you may have skype open which somewhat uses port 80/443 and therefore is blocking it. Shutdown skype if you do so or use a different port for your webapp.
So here's the deal with Azure:
If you open a port from the Azure portal, the firewall in your VM STILL blocks that port. You have to manually go in and create a firewall setting in your VM to keep the port 5000 open for your flask server. Once that is done, you should be able to connect to it.

Quick issue with Python 3.1 http server

I'm have an issue with running the built in Python server that comes with 3.1, this may or may not be an issue with Python, in fact it probably isn't.
I start my server in the correct directory with "python -m http.server 8000" as the documentation suggests (http://docs.python.org/release/3.1.3/library/http.server.html).
When I navigate to that port on my local network with another computer using the url 192.168.2.104:8000 (my local ip and the port) my page loads. When I use my global IP, however, it stops working. Port 8000 is forwarded correctly. I used www.yougetsignal.com to verify that port 8000 was open using my global IP. Why in the world would Chrome be saying "Oops! Google Chrome could not connect to [REDACTED]:8000" then? Other server applications (such as my Minecraft server) work just fine. Is there something I'm missing? Furthermore, why would yougetsignal connect to my port but not Chrome?
With most routers ports are only mapped when someone connects from the outside (internet/WAN). You're testing it from your LAN so basically you're connecting to your router when you use your public IP. Ask a friend to test, i.e. from an outside connection.

Python LDAP Authentication from remote web server

I have a django application hosted on webfaction which now has a static/private ip.
Our network in the office is obviously behind a firewall and the AD server is running behind this firewall. From inside the network i can authenticate using python-ldap with the AD's internal IP address and the port 389 and all works well.
When i move this to the hosted webserver i change the ip address and port that has been openend up on our firewall. For simplicity the port we opened up is 389 however the requests to authenticate always timeout. When logged into webfaction and running python from the shell and querying the ipaddress i get webfactional's general ip address rather than my static ip.
Is this whats happening when i try and auth in django? the request comes from the underlying ip address that python is running on rather than the static ip that my firewall is expecting?
Im fairly clueless to all this networking and port mapping so any help would be much appreciated!
Hope that makes sense?
I would recommend against opening the port on the firewall directly to LDAP. Instead I would suggest making an SSH tunnel. This will put the necessary encryptionn around the LDAP traffic. Here is an example.
ssh -N -p 22 username#ldapserver -L 2222/localhost/389
This assumes that the ssh server is running on port 22 of your ldap server, and is accessible from your web host. It will create a tunnel from port 389 on the ldap server to port 2222 on the web host. Then, you configure your django application on the web host to think that the LDAP server is running on localhost port 2222.
There are quite a few components between your hosted django application and your internal AD. You will need to test each to see if everything in the pathways between them is correct.
So your AD server is sitting behind your firewall. Your firewall has ip "a.b.c.d" and all traffic to the firewall ip on port 389 is forwarded to the AD server. I would recommend that you change this to a higher more random port on your firewall, btw. Less scans there.
With the shell access you can test to see if you can reach your network. Have your firewall admin check the firewall logs while you try one of the following (or something similar with python) :
check the route to your firewall (this might not work if webfaction blocks this, otherwise you will see a list of hosts along which your traffic will pass - if there is a firewall on the route somewhere you will see that your connection is lost there as this is dropped by default on most firewalls):
tracert a.b.c.d
do a telnet to your firewall ip on port 389 (the telnet test will allow your firewall admin to see the connection attempts coming in on port 389 in his log. If those do arrive, that means that external comm should work fine):
telnet a.b.c.d 389
Similarly, you need to check that your AD server receives these requests (check your logs) and as well can respond to them. Perhaps your AD server is not set up to talk to the firewall ?

Categories