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

Cookie "oauth_proxy" not present but Oauth starts and responds with GET - "/oauth2/start?rd=%2F" #495

Open Matrix7867 opened 6 years ago

Matrix7867 commented 6 years ago

Hi,

I'm using oauth2(bitly) with my Jenkins server for Authentication. While starting Oauth2 I'm getting below error: After running the below command:

$ oauth2_proxy -config /etc/oauth.cfg

**2017/11/06 09:16:56 validator.go:23: using authenticated emails file /etc/oauth2_proxy/authenticated_emails.txt
2017/11/06 09:16:56 watcher.go:67: watching /etc/oauth2_proxy/authenticated_emails.txt for updates
2017/11/06 09:16:56 oauthproxy.go:130: mapping path "/" => upstream "http://jenkins.devops:8080"
2017/11/06 09:16:56 oauthproxy.go:157: OAuthProxy configured for Google Client ID: XXXXXXXX-jxxxxxxc3cue59uj7el.apps.googleusercontent.com
2017/11/06 09:16:56 oauthproxy.go:167: Cookie settings: name:oauth_proxy secure(https):false httponly:true expiry:1h0m0s domain:<default> refresh:disabled
2017/11/06 09:16:56 http.go:49: HTTP: listening on 127.0.0.1:4180
2017/11/06 09:17:31 oauthproxy.go:602: 127.0.0.1:41036 ("14.142.151.180") Cookie "oauth_proxy" not present
14.142.151.181 - - [06/Nov/2017:09:17:31 +0000] jenkins.devops GET - "/" HTTP/1.0 "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12) AppleWebKit/602.1.50 (KHTML, like Gecko) Version/10.0 Safari/602.1.50" 403 2478 0.000
14.142.151.181 - - [06/Nov/2017:09:20:10 +0000] jenkins.devops GET - "/oauth2/start?rd=%2F" HTTP/1.0 "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12) AppleWebKit/602.1.50 (KHTML, like Gecko) Version/10.0 Safari/602.1.50" 302 376 0.000**

Jenkins service and Nginx setup is on the same machine. Nginx config is below:

server {
    listen 90;
    server_name jenkins.devops:8080;
    location /
     {
    proxy_pass http://127.0.0.1:4180;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Scheme $scheme;
        proxy_connect_timeout 1;
        proxy_send_timeout 30;
        proxy_read_timeout 30;
}
}

I'm am able to login with oauth2 (Gmail creds) and in turn redirects to my Jenkins page (as expected) but after login to jenkins page, I'm getting following error:

HTTP ERROR 404
Problem accessing /oauth2/callback. Reason:
 Not Found

Any help would be appreciated. Thanks

ploxiln commented 6 years ago

2017/11/06 09:16:56 oauthproxy.go:130: mapping path "/" => upstream "http://jenkins.devops:8080"

server_name jenkins.devops:8080; proxy_pass http://127.0.0.1:4180;

This looks circular

Matrix7867 commented 6 years ago

@ploxiln

Removed port number "8080" from server_name. server_name jenkins.devops; but still no luck.
I'm getting 2017/11/07 12:52:32 http.go:49: HTTP: listening on 127.0.0.1:4180 2017/11/07 12:54:21 oauthproxy.go:602: 127.0.0.1:43670 ("14.142.151.180") Cookie "_oauth2_proxy" not present