Redirects to the wrong URL

Hi there,

I've set up Upsource to work behind a nginx as a reverse proxy just like it's described here: https://www.jetbrains.com/upsource/help/1.0/install_config.html#http-proxy
Base URL is configured like http://10.233.106.177:38280/. It's address of reverse proxy.
Everything looks fine except one thing: redirects to the wrong URL during each login/logout attempt.

For instance I'm clicking "Logout". First request is going here:

http://10.233.106.177:38280/hub/api/rest/oauth2/auth?response_type=token&state=8bee7343-7b11-4418-bbf0-5d0f3302ee9c&redirect_uri=http%3A%2F%2F10.233.106.177%3A38280%2F&client_id=f8270f01-ca4a-4023-bef7-609c9c35d9ba&scope=f8270f01-ca4a-4023-bef7-609c9c35d9ba%200-0-0-0-0%2097488d7a-76cc-4e9f-826b-34af953e02bc&request_credentials=required

With this request I'm obtaining 303 status and header Location with the next URL:


Obviously second request is going nowhere 'cause correct port (38280) is missing. Ok I'm manually putting port there and sending request again. Result is the same - 303 and redirect to the URL without correct port number. After several manual manipulations with the port I've finally logged out. The same story with the login.

First I've checked data/hub/conf/hub-config.properties file. Each URL in this file contains correct port number. Then I've a little bit investigated log files and found there one strange record:

[JetPassUrlDAO                 ] CAS URL: http://10.233.106.177/hub

Probably this record is somehow connected with my problem. So my question is what could be the reason of such a behavior? Look forward to your reply.

Regards,
Artem

0
6 comments

Hi Artem,

Sorry for the delayed response.

We would need some additional information in order to understand what went wrong with your configuration. So, when you have a chance please zip and post entire contents of the this folders - "logs", "conf", located in Upsource home directory.

Thanks in advance.

0
Avatar
Permanently deleted user

Thank you for your support! I've attached desired directories. I was able to reproduce described problem at this timestamp: Mon Jan 19 11:43:26 MSK 2015.

Here's configuration of nginx:

server {

    listen 80;

    server_name 10.233.106.177;

    location  / {

        proxy_set_header X-Forwarded-Host $host;

        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        proxy_set_header X-Forwarded-Proto $scheme;

        proxy_http_version 1.1;

        # to proxy WebSockets in nginx

        proxy_set_header Upgrade $http_upgrade;

        proxy_set_header Connection "upgrade";

        proxy_pass http://localhost:1111/;

    }

}



Attachment(s):
logs_conf.tar.gz
0

Hi Artem,
 
Due to your proxy configuration, listen port is 80, but Upsource is configured with port 38280. Who is listening this port? Do you have another proxy server?    

0
Avatar
Permanently deleted user

Hi Artem,

Actually, network configuration is quite complicated. On this machine is only web-server, which is listening on 80 port. But I'm able to access this machine only through the NAT. So, internal adress is like 192.168.something:80 which is mapped to 10.233.106.177:38280. Sorry, I've forgotten to mention such important part of configuration.

0

Hello, Artem!

I have investigated your issue.
it seems that information about port has been lost while request had been passed through the NAT.

Could you please try to change proxy configuration
defining
proxy_set_header X-Forwarded-Host 10.233.106.177:38280;
instead of
proxy_set_header X-Forwarded-Host $host;
?

(alternatively, you might change the NAT mapping from 10.233.106.177:38280 --> 192.168.<...>:80 to 10.233.106.177:38280 --> 192.168.<...>:38280 and configuring nginx to listen on port 38280)

Sincerely,
Alexey Barsov

0
Avatar
Permanently deleted user

Hello Alexey,

Thank you for the hint, it works!

Regards,
Artem

0

Please sign in to leave a comment.