lapis icon indicating copy to clipboard operation
lapis copied to clipboard

Question: How to config a lapis production server on Ubuntu?

Open mabeebam opened this issue 10 years ago • 6 comments

Hi,

Any help (advice, tutorials, links) on configuring a lapis server in production mode on an Ubuntu system would be highly appreciated.

My specific problem I maintain my server code with git, so I want to git clone my git repository to /home/username/ Now I want to configure nginx/openresty such that it points to /home/username/lapis-lua-code-directory

Why? Such that any future redeployments are simple git pulls and sudo service nginx restart. How to set this up?

Thanks for your help in advance!

BR

mabeebam avatar Sep 03 '15 07:09 mabeebam

There aren't any tutorials, but I'd be glad to help you out and maybe we can assemble one in the process. I run my production lapis under a regular user and typically have another nginx that starts as root as a reverse proxy. The other approach is to have lapis' nginx spawn as root then downgrade itself to a user. The advantage of using one nginx to reverse proxy is that you can run many lapis apps on one machine pretty easily.

Regarding starting stopping the server, I don't use ubuntu, but it should be fairly easy to write a service file for it. You just need to chdir to the lapis and run either lapis server or lapis build depending on if you want to start or restart.

For git integration, you'll have to write a post commit hook that does the right thing. Haven't done this yet so I can't offer any advice.

I suggest creating a lapis_environment.lua file on your production server that returns the string "production", this will set the default environment to production so you don't have to worry about passing production to lapis start and lapis build.

leafo avatar Sep 03 '15 20:09 leafo

Hi Leafo,

Thanks for sharing your ideas and your setups. Yes, we can set up a short tutorial and put it on the lapis-wiki.

Reverse proxy sounds reasonable to me. I will dig into it and come back to you...

Best!

mabeebam avatar Sep 06 '15 19:09 mabeebam

Hi Leafo,

Reverse proxy was easily setup by proxy_pass. Good source of information for me was: https://www.nginx.com/resources/admin-guide/reverse-proxy/

When your lapis servers should be accessible via HTTPS are you configuring both the reverse proxy and the local nginx server with ssl on;? Or just the reverse proxy?

BR

mabeebam avatar Sep 08 '15 15:09 mabeebam

In the reverse proxy scenario I just have SSL on the main nginx server, and the configs point to the certs for each project. It's one downside since it makes it harder to keep everything associated with a single app in one place.

leafo avatar Sep 26 '15 19:09 leafo

Just a bit off-topic and I don't really want to hijack this thread but after so much effort to make it work on an arch linux machine I decided to create a vagrant box for that and it seems to work pretty fine. You can give it a try if you want. Any suggestions/remarks would be more than welcome. :) https://github.com/ounos/lapis-vagrant

ilazaridis avatar Nov 28 '15 01:11 ilazaridis

@leafo I'm curious to see a more concrete example of how you set up proxying with NGINX. I use something like this myself, but I don't know if it's the best.

Edit: Also, I've been getting better at setting things up in an automated fashion, so I would like to help with getting some stuff written for how to do that, but I'm not sure what to do just yet.

TangentFoxy avatar Aug 03 '16 07:08 TangentFoxy