Error Redeeming Code & Internal Error 500
I am running a machine with and external IP and 3 VMs.
- All machines run nginx.
- Host machine forces https traffic and proxies respective sub-domains to the correct VM (which use internal IPs obviously)
- Each VM has their own Let's Encrypt cert
All VMs have internal sites on them alongside GitLab.
- GitLab is the Oauth Provider
- If the GitLab URL is entered user is sent to the GitLab Sign-In
- If internal site URL is entered user is proxied through the oauth2-proxy
All but one VM works fine. All VMs have the same nginx sites-enabled file with differences being the paths to their Certs and their sub-domain URL and the IPs.
2 of the 3 VMs work great but the most recently created one gives this error output:
oauth2_proxy-2.2.0.linux-amd64.go1.8.1/oauth2_proxy -config=/home/user/oauth.conf
2017/07/12 15:33:31 oauthproxy.go:130: mapping path "/" => upstream "http://localhost:8888"
2017/07/12 15:33:31 oauthproxy.go:157: OAuthProxy configured for GitLab Client ID: 4***7
2017/07/12 15:33:31 oauthproxy.go:167: Cookie settings: name:_oauth2_proxy secure(https):false httponly:true expiry:24h0m0s domain:sub.domain.com refresh:after 1h0m0s
2017/07/12 15:33:31 http.go:49: HTTP: listening on 127.0.0.1:4180
2017/07/12 15:33:50 oauthproxy.go:602: 127.0.0.1:46608 ("192.168.122.1") Cookie "_oauth2_proxy" not present
192.168.122.1 - - [12/Jul/2017:15:33:50 -0400] sub.domain.com GET - "/test-test-test/" HTTP/1.0 "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:54.0) Gecko/20100101 Firefox/54.0" 403 2508 0.000
192.168.122.1 - - [12/Jul/2017:15:33:52 -0400] sub.domain.com GET - "/test-test-test/oauth2/start?rd=%2Ftest-test-test%2F" HTTP/1.0 "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:54.0) Gecko/20100101 Firefox/54.0" 302 362 0.000
2017/07/12 15:34:25 oauthproxy.go:527: 127.0.0.1:46624 ("192.168.122.1") error redeeming code Post https://sub.domain.com/test-test/oauth/token: dial tcp <PUBLIC_IP>:443: i/o timeout
2017/07/12 15:34:25 oauthproxy.go:349: ErrorPage 500 Internal Error Internal Error
192.168.122.1 - - [12/Jul/2017:15:33:55 -0400] sub.domain.com GET - "/test-test-test/oauth2/callback?code=9f14e22755ae157beb81b210d415af98f68f496bebf87f5ac8830c952f0bdca6&state=d6eeeb0bb7fcf75c29fec4fca89d188f%3A%2Ftest-test-test%2F" HTTP/1.0 "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:54.0) Gecko/20100101 Firefox/54.0" 500 346 30.001
And here is the offending VM's nginx config:
server {
listen 80;
#GitLab
location /test-test/ {
proxy_pass http://127.0.0.1:8081/test-test/;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Ssl on;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Port 443;
}
#Internal Site
location /test-test-test/ {
proxy_pass http://127.0.0.1:4180;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Ssl on;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Port 443;
}
}
the key error message appears to be
2017/07/12 15:34:25 oauthproxy.go:527: 127.0.0.1:46624 ("192.168.122.1") error redeeming code Post https://sub.domain.com/test-test/oauth/token: dial tcp <PUBLIC_IP>:443: i/o timeout
... so it failed to connect to your gitlab instance
But see I am able to navigate to gitlab just fine.
When I press sign in with gitlab I am sent to the page just fine and I log in and that's when I see the error.
Are there any starting points for trouble shooting that you could offer?
Like I said, my other VMs are working just fine with Oauth so I don't know if it is just a missed config option in gitlab or what. I should also note that i have disabled firewalls on the VMs to troubleshoot as well.
It appears that, while your browser can connect to your gitlab, your oauth2_proxy cannot connect to it, running from where it is.
I'm not sure how to fix it but I have used the VM that is giving me issue and tried to connect to any of the VMs that are hosted by the same machine and cannot see them.
On the other hand however, I am able to use the other 2 VMs to see both themselves and each other.
Alright so I've figured it out. After running the route command on a working and the non-working VM I was able to see a discrepancy in the default gateway.
What ended up working was that I had to open the /etc/hosts file and add the default gateway to the list and give it the sub.domain.com address for that VM so that it can be routed through the Nginx install on the host machine before being sent back to itself.
Thanks @ploxiln for the help. Your input lead me in the right direction.