Skip to content

Instantly share code, notes, and snippets.

@mngshm
Last active October 28, 2024 11:52
Show Gist options
  • Save mngshm/72e32bd483c2129621ed0d74412492fd to your computer and use it in GitHub Desktop.
Save mngshm/72e32bd483c2129621ed0d74412492fd to your computer and use it in GitHub Desktop.
This is a gist for explaining how to run ente web app as a systemd service

Running the Web App as a Systemd Service

You can also run the web app as a systemd service and reverse proxy it with a webserver like Nginx or caddy.

Below is a battle tested systemd service example:

[Unit]
Description=Run Ente Web as a service

[Service]
Type=simple
Restart=always
WorkingDirectory=/path/to/ente/web-app
Environment=NEXT_PUBLIC_ENTE_ENDPOINT=http://localhost:8000
ExecStart=/usr/bin/yarn dev

# If the above doesn't work, try this as an alternative:
# ExecStart=yarn dev  

# You can add this to verify if yarn is installed
# ExecStartPre=yarn --version

[Install]
WantedBy=multi-user.target

Note: Please do not forget to set the right path for WorkingDirectory in the above.

To debug in case of any issues, you could use journalctl utility or enable logging in systemd by adding 2 more lines to the ente.service file.

# The log file paths can be customised
StandardOutput=/var/log/ente-out.log 
StandardError=/var/log/ente-err.log 

Follow the below steps to configure and enable the service.

sudo touch /etc/systemd/system/ente-web.service 
sudo systemctl enable ente-web.service 
sudo systemctl daemon-reload && sudo systemctl start ente-web.service  

Reverse Proxy

Finally, reverse proxy the web app with the help of caddy or nginx.

I prefer using caddy as it saves the pain of setting up Lets Encrypt certificates manually. My caddy configuration looks something like the below:

your-ente-site-name.com {
        reverse_proxy localhost:3000
        log {
                level error
        }
        tls <my-email> # optional
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment