Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Harden Traefik systemd service #4302

Merged
merged 2 commits into from Jan 7, 2019

Conversation

jacksgt
Copy link
Contributor

@jacksgt jacksgt commented Dec 17, 2018

Since Traefik is running as root on the system, it makes sense to
apply various lock down measures to keep the system as safe as possible.

Includes mounting most of the directories as read-only or even making them
inaccessible, restricting kernel modifications and limiting the number of
processes the unit may spawn.

Also add checks at service startup to ensure all required files are present.

@jacksgt

This comment has been minimized.

@alemairebe
Copy link

it could also be run by a standard user with these 2 under [Service]
User=traefik
AmbientCapabilities=CAP_NET_BIND_SERVICE

@jacksgt
Copy link
Contributor Author

jacksgt commented Dec 22, 2018

@alemairebe I thought about adding that too, but then again it requires setting up a user for traefik and assigning appropriate permissions to /etc/traefik.toml and /etc/acme.json.
Nothing complicated, but at least its not documented anywhere.

Maybe we can add that as a comment to the service file?

[Service]
# Run traefik as its own user (create new user with: useradd -r -s /bin/false -U -M traefik)
#User=traefik
#AmbientCapabilities=CAP_NET_BIND_SERVICE
ExecStart=...

@alemairebe
Copy link

@jacksgt I guess that would be a good first step :-)
I have no idea how useful it can be to the whole community and users.

@jacksgt
Copy link
Contributor Author

jacksgt commented Jan 2, 2019

@mmatur Could you please review this PR?

Copy link
Member

@mmatur mmatur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @jacksgt,

First of all thanks for your interest in the project. In this contribution all new params should be commented because there are not mandatory.

Only few comments

contrib/systemd/traefik.service Outdated Show resolved Hide resolved
contrib/systemd/traefik.service Outdated Show resolved Hide resolved
@jacksgt
Copy link
Contributor Author

jacksgt commented Jan 4, 2019

I added brief comment for all new parameters (for more in-depth information the systemd man page should be consulted).

@ldez ldez removed the request for review from a team January 4, 2019 16:08
@ldez ldez removed the request for review from a team January 4, 2019 16:08
Copy link
Member

@mmatur mmatur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@dtomcej dtomcej left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
:shipit:

Copy link
Member

@ldez ldez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

jacksgt and others added 2 commits January 7, 2019 17:54
Since Traefik is directly connected to the internet, it makes sense to
apply various lock down measures to keep the system as safe as possible.

Includes mounting most of the directories as read-only or even making them
inaccessible, restricting kernel modifications and limiting the number of
processes the unit may spawn.

Also add checks at service startup to ensure all required files are present.

Additionally documents how to set up a separate user for traefik and run the
service as that user.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants