Redirects to localhost:8000 after moving to https

Hello,

I’ve got a problem after moving Seafile Server 6.0.7 to https (on Windows Server 2016 and IIS 10). All works fine except web interface. I’m trying to access it via https://seafile.company.com, but it redirects to http://localhost:8000/accounts/login?next=/.

There is a IIS redirect rule.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <security>
            <requestFiltering>
                <requestLimits maxUrl="6144" maxQueryString="4096" />
            </requestFiltering>
        </security>
        <rewrite>
            <rules>
                <clear />
				<rule name="HTTP/S to HTTPS Redirect" enabled="true" stopProcessing="true">
					<match url="(.*)" />
					<conditions logicalGrouping="MatchAny">
						<add input="{SERVER_PORT_SECURE}" pattern="^0$" />
					</conditions>
					<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" />
				</rule>
                <rule name="Seafile" stopProcessing="true">
                    <match url="(.*)" />
                    <action type="Rewrite" url="http://localhost:8000/{R:1}" />
                    <serverVariables>
                        <set name="HTTP_X_FORWARDED_HOST" value="{HTTP_HOST}" />
                        <set name="HTTP_X_FORWARDED_SCHEME" value="https" />
                        <set name="HTTP_X_FORWARDED_PROTO" value="https" />
                    </serverVariables>
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

The same rule works perfectly with other internal services except Seafile.

Seafile configs:

ccnet.conf:

[General]
USER_NAME = company-seafile
ID = 44fece35473682084bfa71f7b3236ac170363b4d
NAME = company-seafile
SERVICE_URL = https://seafile.company.com

[Network]
PORT = 10001

[Client]
PORT = 13418

[LDAP]
HOST = localhost:389
BASE = dc= company,dc=local
USER_DN = seafile@company.local
PASSWORD = password
LOGIN_ATTR = mail

seafile.conf:

[database]
type = sqlite

[network]
port = 12001

[fileserver]
port = 8082

[seahub]
port = 8000
fastcgi = false

It seems I need to set some extra IIS redirection rule specially for Seafile? Have anybody faced with the similar problem?

Thank you.

Don’t know if it will solve your problem, but why you have in SERVICE_URL space between subdomain and domain?

http://tjsa.info/2016/02/15/seafile-ssl-on-iis/

Sorry, holantomas. Actually there is no space in the config. This is type only here in forum.

Unfortunately this topic didn’t help. I just changed it exactly as described there.

Web UI settings have higher priority than those in the config file. Did you set those?

Yes, there are correct URLs in the Web UI settings:
SERVICE_URL - https://seafile.company.com
FILE_SERVER_ROOT - https://seafile.company.com/seafhttp

@DerDanilo I think it’s not on settings cause by experiences, it work with different settings and only download and upload files are messed up (redirected).

@alexander.samuilov
Can you provide change IIS settings?

It is completely as in the guide above. Please see it here: https://www.dropbox.com/sh/o2mmhtc218h9qom/AABekwxcBLNcXhpZ-pHb9jDia?dl=0

Or some other settings can say more?

OK, please clean seafile/seahub cache and IIS(if have some). And restart your IIS, seafile and seahub

It doesn’t help :frowning:

There are ending my ideas. You have to wait for someone who knows IIS or just try to google proxy_pass on IIS.

Thank you for helping. Will try something else :slight_smile:

Why not try apache/nginx on Windows. Is the docker image an option for you?

Not really want to try it - we have several services working on IIS. It will make harder to understang what is going on in the server. But of course, if there will no solution, I will try any other solution.