Is it possible to use Elm with a reverse proxy?

Hi, beginner question here, though I think its more of server question than an Elm question.

I was wondering if it makes sense have a reverse proxy for Elm? For example, with apache/nginx/php you can use one server run php, and the other to serve (and cache) static files. Elm only generates static files.

Would there be any optimisations to serve some static files (eg images, css) on port 80 or 443 for nginx server, and serve html and js on an elm proxy server on port 8000 with reactor? Even though html and js files are static? Out of curiousity, I tried use a nginx/reactor reverse proxy set up, only to realise it doesn’t work because of the reactor file viewing component.

Would one just load the elm project as static files on Nginx? Are their any specific best practices using Elm with Nginx?


I think reactor is made only for development purposes. For production you should compile elm to js with something like this elm make src/Main.elm --optimize --output=elm.js and serve it with all the other static content you have.

:+1: thank you for the optimised output. I suspected that for reactor. cheers !

There’s no need to do anything special with Elm files when it comes to reverse proxies. You’re not running a server-side app that is accessed on some high number port (like 8000) that you need to proxy to 80. Reactor is there solely for you to get instant feedback of your development before you put it into production.

When you are ready to do so, Elm’s output is just a static javascript bundle you send to the client side. Nothing to do on Nginx other than direct your endpoint to the static files on disk.

What you DO want to take a look at, is how to get your project ready for production. Best practices on that can be found in the Elm docs.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.