Hi Carlos,
Posting this here for posterity, even if you do not need it anymore.
I have since moved my setup to nginx + oauth2-proxy + requesttracker5.0.7 and it’s working nicely. I will describe my configuration in the hopes that it helps someone. It took a fair bit of stuffing about to get it working but it works nicely now.
Please note, my oauth2-proxy server is on another host to my request-tracker server, so I enforce HTTPS between the two and limit connection with firewall. You might be able to skip the oauth2-proxy ssl certificate and use http://127.0.0.1:4180 in the RT5 nginx configuration, if they are on the same server.
This is on ubuntu 24.04.
Azure enterprise app
Create an ‘app registration’.
Note the <client id>, <tenant id>, and create a client secret. note the <client secret value>.
give consent to openid on Microsoft Graph. oauth2-proxy docs have a nice video: https://youtu.be/IUNfxhOzr4E
Setup oauth2-proxy
Install a DNS record for oauth.your.domain.here pointing at what will be your oauth server.
On that host, install certbot and run:
apt install python3-certbot-nginx
certbot certonly -d oauth.<your.domain.here> --agree-tos --nginx -m whatever@your.domain.here
create an oauth2-proxy user:
adduser oauth2-proxy
give oauth2-proxy read access to the ssl certificate from letsencrypt by copying the ssl certs after renewal via hook.
mkdir -p /etc/oauth2-proxy/ssl
nano /etc/letsencrypt/renewal-hooks/deploy/oauth.<your.domain.here>.sh
/etc/letsencrypt/renewal-hooks/deploy/oauth.<your.domain.here>.sh:
#!/bin/sh
pathtoyourcertsdir="/etc/oauth2-proxy/ssl"
domain="oauth.<your.domain.here>"
basedomain="$(basename $RENEWED_LINEAGE)"
youruser="oauth2-proxy"
yourgroup="$(id -ng $youruser)"
reloadcommand="systemctl restart oauth2-proxy.service"
if [ "$domain" = "$basedomain" ];then
cp "$RENEWED_LINEAGE/fullchain.pem" "$pathtoyourcertsdir/server_cert.pem"
cp "$RENEWED_LINEAGE/privkey.pem" "$pathtoyourcertsdir/server_key.pem"
chown $youruser:$yourgroup "$pathtoyourcertsdir/server_cert.pem"
chown $youruser:$yourgroup "$pathtoyourcertsdir/server_key.pem"
$reloadcommand
fi
test renewal with:
RENEWED_LINEAGE=/etc/letsencrypt/live/oauth.<your.domain.here> /etc/letsencrypt/renewal-hooks/deploy/oauth.<your.domain.here>.sh
ls /etc/oauth2-proxy/ssl
# (should see two files there, the certficate and key)
Download and install oauth2-proxy:
wget https://github.com/oauth2-proxy/oauth2-proxy/releases/download/v7.8.1/oauth2-proxy-v7.8.1.linux-amd64.tar.gz
tar xzvf oauth2-proxy-v7.8.1.linux-amd64.tar.gz
cp oauth2-proxy-v7.8.1.linux-amd64/oauth2-proxy /usr/bin/oauth2-proxy
Generate a <cookie secret> with openssl:
openssl rand -base64 32 | tr -- '+/' '-_'
Configure oauth2-proxy:
nano /etc/oauth2-proxy/oauth2-proxy.cfg
Add the following config lines:
/etc/oauth2-proxy/oauth2-proxy.cfg:
http_address = "127.0.0.1:4180"
https_address = "0.0.0.0:4181"
reverse_proxy = true
tls_cert_file = "/etc/oauth2-proxy/ssl/server_cert.pem"
tls_key_file = "/etc/oauth2-proxy/ssl/server_key.pem"
email_domains = [
"<your.domain.here>"
]
client_id = "<client-id>"
client_secret = "<client-secret>"
scope = "openid"
cookie_secret = "<cookie-secret>"
# configure for Azure AD
provider = "entra-id"
oidc_issuer_url = "https://login.microsoftonline.com/<tenant-id>/v2.0"
set_xauthrequest = true
Setup systemd unit file:
wget https://raw.githubusercontent.com/oauth2-proxy/oauth2-proxy/refs/heads/master/contrib/oauth2-proxy.service.example
cp oauth2-proxy.service.example /etc/systemd/system/oauth2-proxy.service
systemctl daemon-reload
systemctl enable --now oauth2-proxy
check the output of
systemctl status oauth2-proxy
Should be running okay. Check the output of
ss -ltpn
Should show oauth2-proxy listening on *:4181.
Allow firewall
ufw allow proto tcp from <rt.server.ip.address> to any port 4181
systemd for requesttracker cgi
Create two files:
/etc/systemd/system/rt5.service:
[Unit]
Description=RT5 ticketing system
After=syslog.target mysql.service
Wants=mysql.service
[Service]
Type=simple
ExecStart=/opt/rt5/sbin/rt-server.fcgi
User=www-data
Group=www-data
StandardInput=socket
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=rt5
[Install]
WantedBy=multi-user.target
/etc/systemd/system/rt5.socket:
[Unit]
Description=RT5 Socket for web server
[Socket]
ListenStream=/var/run/rt5.socket
Accept=false
SocketUser=www-data
SocketGroup=www-data
SocketMode=0600
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=rt5
[Install]
WantedBy=sockets.target
Request Tracker certbot
On the requesttracker server:
apt install python3-certbot-nginx
certbot certonly -d <your.rt.domain.name> --agree-tos --nginx -m whatever@your.domain.here
Nginx Settings
/etc/nginx/rt5-cgi.conf:
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME "";
fastcgi_param PATH_INFO $uri;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param REMOTE_USER $email;
systemctl enable --now rt5.service
systemctl status rt5
/etc/nginx/sites-available/rt.conf:
server {
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/<your.rt.domain.here>/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/<your.rt.domain.here>/privkey.pem;
server_name <your.rt.domain.here>;
access_log /var/log/nginx/access.<your.rt.domain.here>.log;
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
location /oauth2/ {
proxy_pass https://oauth.<your.domain.here>:4181;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Auth-Request-Redirect $request_uri;
}
location = /oauth2/auth {
proxy_pass https://oauth.<your.domain.here>:4181;
proxy_set_header Content-Length "";
proxy_pass_request_body off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Auth-Request-Redirect $request_uri;
}
location / {
auth_request /oauth2/auth;
auth_request_set $user $upstream_http_x_auth_request_user;
auth_request_set $email $upstream_http_x_auth_request_email;
add_header X-test $email always;
error_page 401 =403 /oauth2/sign_in;
client_max_body_size 100M;
include /etc/nginx/rt5-fcgi.conf;
fastcgi_pass unix:/var/run/rt5.socket;
}
location /REST/1.0/NoAuth/ {
auth_request off;
include /etc/nginx/rt5-fcgi.conf;
fastcgi_pass unix:/var/run/rt5.socket;
}
}
Configure RT5
edit RT_SiteConfig.pm
/opt/rt5/etc/RT_SiteConfig.pm:
Set($WebRemoteUserAuth, 1);
Set($WebFallbackToRTLogin,1);
Final Notes
Make sure that your users USERNAME matches the email address from Azure AD.
Make sure you assign you users to the enterprise application.
Hope this helps someone!