Search code examples
pythonnat

Natting of AWS EC2 public IP and primary private ip


I am trying to set up a simple web service but when I do an HTTP request to the port 8080 of my server nothing happens... I have discovered that the simple python server that i have set up listens on the 8080 port of the primary private IP and not on the public IP port.

How can I send the HTTP requests to the python script? Do I have to NAT?

I am on ubuntu 14.04 server

This is the simple python web server

from BaseHTTPServer import BaseHTTPRequestHandler
import urlparse

class GetHandler(BaseHTTPRequestHandler):

    def do_GET(self):
        parsed_path = urlparse.urlparse(self.path)
        self.wfile.write(parsed_path.query[2:])
        return

if __name__ == '__main__':
    from BaseHTTPServer import HTTPServer
    server = HTTPServer(("0.0.0.0", 8080), GetHandler)
    print 'Starting server, use <Ctrl-C> to stop'
    server.serve_forever()

Solution

  • The problem was that I didn't set a rule for port 8080! Thank you to everybody!