bitly / oauth2_proxy

A reverse proxy that provides authentication with Google, Github or other provider
MIT License
5.1k stars 1.21k forks source link

init.d script? #39

Open artooro opened 10 years ago

artooro commented 10 years ago

How are you guys running this script in the background? I have it working but would be nice if it was an init.d script that would start automatically and run in the background.

Do you have an example?

LukeHandle commented 10 years ago

This seems to be a fairly aceptable init.d template: https://github.com/fhd/init-script-template

Basically, they start it then redirect the outputs to 2 log files, before grabbing the PID and putting it in a file. /path/to/service >> /path/to/log/stdout.log 2>> /path/to/log/stderr.log &

Personally, I am using systemd:

[Unit]
Description=Google OAuth Proxy

[Service]
User=google_auth_proxy
Group=google_auth_proxy
EnvironmentFile=/etc/sysconfig/google_auth_proxy
ExecStart=/usr/lib/google_auth_proxy/google_auth_proxy --redirect-url=https://example.com/oauth2/callback --authenticated-emails-file=/usr/lib/google_auth_proxy/authenticated-emails  --upstream=http://localhost:4140/

[Install]
WantedBy=multi-user.target

Hope this helps.

vjanelle commented 9 years ago

There's also the pleaserun gem which can generate this for you.

gbagnoli commented 9 years ago

here is one for upstart in case it's needed

description "Google auth proxy"
start on (local-filesystems and net-device-up IFACE!=lo)
stop on runlevel [016]
setuid <user>
setgid <group>
respawn
respawn limit 10 5
exec /usr/local/bin/google_auth_proxy --redirect-url=https://example.com/oauth2/callback --authenticated-emails-file=/usr/lib/google_auth_proxy/authenticated-emails  --upstream=http://localhost:4140/ <other_options>
lorello commented 9 years ago

Thanks Giacomo! :-)

artooro commented 9 years ago

The template @LukeHandle linked to is working great for me!

bangert commented 8 years ago

a systemd service file has been added to the contrib directory https://github.com/bitly/oauth2_proxy/blob/master/contrib/oauth2_proxy.service.example

ajsharp commented 8 years ago

It would be great to add upstart and system V examples for the time being (those aren't going anywhere anytime soon).