KayGee
KayGee

Reputation: 45

Python Bottle app not available to external machines when hosted with nginx

I developed a bottle app which i want to host on a local machine. I have my app listening on port 8080 of the windows machine i'm running it on. I did port forward 8080 to accept incoming traffic, both on windows firewall and my vpn that has a dedicated IP adress. (i can share the vpn provider if relevant)

The catch is that this setup works for external ip adresses if the requests are made directly to the bottle paste server when this server is listening on port 8080.

My problem is that serving images to external machines is excruciatingly slow. My assumption is that this is due to using bottle directly for hosting.

now i want to try nginx as a production environment, both to learn and to see what impact this has on the performance of my server.

I use the following nginx.conf file:

worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    keepalive_timeout  65;

    server {
        listen 0.0.0.0:8080;
        server_name _;

        location / {
            proxy_pass http://localhost:8081;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}

I now have nginx listen on port 8080 an my bottle app listen on 8081

My bottle app is a paste server (from paste import httpserver in python) started by:

httpserver.serve(app, host='0.0.0.0', port=8081, threadpool_workers=32, request_queue_size=100, server_version="Unknown/1.0")

The strange thing is that on the local machine i can access my app just fine making requests to the <VPN_IP>:8080

but from external sources i cannot. I can not even ping the server anymore.

My question now is: Does nginx have any impact in port forwarding or does it have any additional requirements that can cause this?

Upvotes: 0

Views: 24

Answers (0)

Related Questions