Sometimes getting caught up in the configuration of gunicorn or uWSGI with the configuration of nanobox can be confusing. If you are not getting what you expect, starting here can be a good way to know if you have ports configured properly.
When running nanobox run
remember that:
- You can hit any port on the that development machine.
- You must start any processes you want running -- it does not start them for you.
- The ports you specify in the web nodes do not have anything to do with
nanobox run
.
As a convenience the dev machine does forward port 80
to 8080
.
> nanobox run
...
--------------------------------------------------------------------------------
+ You are in a Linux container
+ Your local source code has been mounted into the container
+ Changes to your code in either the container or desktop will be mirrored
+ If you run a server, access it at >> 172.20.0.18
--------------------------------------------------------------------------------
/app $ python3 -m http.server --bind 0.0.0.0 8080
Serving HTTP on 0.0.0.0 port 8080 (http://0.0.0.0:8080/) ...
172.20.255.254 - - [07/Feb/2018 16:43:43] "GET / HTTP/1.1" 200 -
In the browser I can visit http://172.20.0.1:8080
(or
http://172.20.0.1
since my process is running on port 8080
) and be
served the index page. But if my process was on some other port, say
8000
, I would have to hit that port directly; nanobox dev is not going to
forward anything magically.
But when running a proper deploy (including dry-run) you must hit the ports
mapped by the web components. If you define none it is http:80:8080
and
http:443:8080
by default. That is to say that nanobox will send all
traffic from 80
and 443
to your web node on 8080
. You do not need
to handle any SSL -- nanobox handles SSL termination for you.
> nanobox deploy dry-run
...
--------------------------------------------------------------------------------
+ Your app is running in simulated production environment
+ Access your app at >> 172.20.0.19
--------------------------------------------------------------------------------
Connected to streaming logs:
ctrl + c to quit
------------------------------------------------
waiting for output...
Wed Feb 07 16:53:00 2018 web.main (app[daemon]) :: 172.20.0.19 - - "GET / HTTP/1.1" 200 -
In the browser I can now hit my app deployed to dry-run at both
http://172.20.0.1
and https://172.20.0.1
. But I cannot hit it on port
8080
any more.
- Don’t run any of your processes on any port <
1024
-- that will requiresudo
and will likely cause all sorts of issues (as well as opening security risks that just aren’t necessary). - In addition to the above, don’t (in fact, you can’t) run anything on ports
80
or443
because the nanobox load balancer handles those.