How do you run phx.server on other ports or remove the need to provide it for deployment? Now my domain name need :4000 for users to connect.
There are plenty of options, the most common are:
dockerand map external 80 to internal 4000
- Use a reverse proxy, it can also do the HTTPS stuff for you, while phoenix stays HTTP
iptablesto map port 80 -> 4000
- Start your application with the necessary privilges to bind to port 80/443 DO NOT DO THIS UNLESS YOU KNOW WHAT YOU ARE DOING
So basically exactly the same options you had with ruby, python or go…
all my connections are https, so reverse proxy is my only option. Do away with cowboy use nginx? I found this https://medium.com/@a4word/setting-up-phoenix-elixir-with-nginx-and-letsencrypt-ada9398a9b2c. What do you think?
All the other options are valid as well, but you need to configure phoenix to do the encryption.
I’m not sure though what you mean with “Do away with cowboy use nginx?”.
nginx is one of many solutions I’ve seen in the wild. There’s also
HAProxy and many others.
Oh I still run cowboy with nginx.
As @NobbZ says, there’s plenty of ways to configure Phoenix ports. An advanced trick is that you can bundle more than one phoenix app into a single release, each Phoenix app listening on it’s own port. For example you could have your end-user app listening on port 4010, an admin app listening on port 4020, and a GraphQL Api listening on port 4030. Not a beginner technique, but as you gain more experience with the framework, using multi-apps can be a nice way to organize your work.
@Nvim - here’s a general approach for how you can build your own multi-phoenix example. 1) create an umbrella app with an
apps/myapp_web subdirectory. 2) Create another phoenix app under the
apps directory (using
mix phx.new myapp2_web --no-ecto) 3) configure the port settings on myapp2_web to listen on another port 4) start everything at the root of your umbrella with
mix phx.server. IMO it’s quite a nice learning exercise to build familiarity with the tooling.