Changing Seafile default port (443) in CentOS

I set up a new server in CentOS 7 using the auto configuration script provided by Seafile.
I’ve gotten everything working now, but I need to change the default port (443) for the web interface.
I’m no Linux guru, so can anyone offer any advice?
The reason behind needing to change the port is that 443 is already assigned on my router to a different server, so I’ve had to use an alternate external port pointing to 443 internally.

Assuming that your installation uses nginx (which auto configuration script you are talking about?), you could go to nginx directory (/etc/nginx/).

I’m not sure how it is with CentOS, but I assume that it’s the same as debian, so you should have there a directory tree like this:

root@bananapi:~# tree -d /etc/nginx /etc/nginx ├── conf.d ├── modules-available ├── modules-enabled ├── sites-available │ ├── default │ ├── seafile.conf ├── sites-enabled ├── snippets └── ssl
You will have to backup and open the file: “seafile.conf” (or whatever it is called in your case) in /etc/nginx/sites-available (see tree above) and change the port 443 within this file to what you need:

root@bananapi:~# nano /etc/nginx/sites-available/seafile.conf

server {
listen 80;
server_name your-dns-adress;
return 301 https://$http_host$request_uri;
}

server {
listen 443 http2;
server_name your-dns-adress;
ssl on;
ssl_certificate /etc/nginx/ssl/seafile.crt;
ssl_certificate_key /etc/nginx/ssl/seafile.key;

proxy_set_header X-Forwarded-For $remote_addr;
    location / {
    fastcgi_pass    127.0.0.1:8000;

.
.
.

Just change the port number that I marked bold.

save the file and restart nginx via (I think this command working for CentOS):

service nginx restart

Then should be able to reach seahub at the new port if you have forwarded it in your router.

1 Like

I thought I had it sorted but I think there’s something else going on I’m not fully understanding.
So the first part:

…means it listens on port 80 then redirects to port 443 (as it refers to https in the URL).
If I change the port 443 to say 444 (just as an example), and then change my url in my browser to 444, nothing happens.
I’ve run a port scanner on my server when 443 is set in the conf file and it shows the port is open (left)
Now, when I change the conf file and alter 443 to 444 and port scan, I don’t see port 444 open (right)

Can I assume this is a firewall thing and I need to alter something in CentOS somewhere to open any additional ports?

Thanks for the initial reply. You’ve set me in the right direction on fixing this issue.

I opened a port in the firewall in CentOS and can now access Seafile via that port. Just need to readjust some of the seafile config files accordingly and change the NAT on my router.

As a reference for others using CentOS, I checked for what ports were available using:
iptables -vnL
Then I used the following to open a port (substitute PORT_TO_OPEN with your new port):
firewall-cmd --zone=public --add-port=PORT_TO_OPEN/tcp --permanent
Then I ran this command to load the new changes:
firewall-cmd --reload

Hi,
I’m able to change the default ssl port to 444 for example.
I can connect to web interface with https://myip:444
But i can’t synchronize a library with the Ubuntu client.
The client show me the library but when i launch the synchronization, i have this message : “can’t establish a secure connection ; check your SSL certificate”.
And if i do a right click and select “see the library in cloud”, i try to open https://myip/#common/lib/92ae17c7-14ab-48ca-5687-ef8cc2b3ba98/ (and not https://myip:444#common/lib/92a....)

I have already modify SERVICE_URL ( https://myip:444) and FILE_SERVER_ROOT ( https://myip:444/seafhttp)
Is there a file to modify ?

thanks for yours tips

ok, i’ve just found the problem : a self certified certificate and i forget to configure client to not check the certificate.
:sweat_smile:

there still the problem of the bad url when i launch “see the library in cloud”, but i’ll post this in seafile client section.