Domain name redirecting to IP in address bar, and HTTPS redirecting to HTTP

Hello all, im rather new here, and worked a little with nextcloud before, but now i want to make a fully dependable system based on nextcloud :slight_smile:

Currently my network set up is as follows:
outside world -> apartment block firewall = (forwarded) 8087:firewall to 443:routerIP / 8086:firewall to 80:routerIP -> router 80/443 -> server 443/80

im also using No-IP with paid hostname and DNS but im having to use a port 80 redirect to my ip because of the firewall

i can access my server using http://domain.com but then it redirects to my IP address: xx.xx.xx:8086

i was fine with this while i was setting up the system, but now i want to use SSL / HTTPS and have my domain name show in the address bar and not the public IP.

i have been playing around a little, and managed to gain access using http(s)://XX.XX.XX.XX:8087 but this shows up as insecure, and when i type in my domain name (redirect currently set to :8087) it redirects to http://domainname.com and then i get bad request from apache:

You’re speaking plain HTTP to an SSL-enabled server port.
Instead use the HTTPS scheme to access this URL, please.

Im also trying to use letscrypt, and ive already generated the certificates

Any help would be greatly appreciated in allowing me to get the domain name showing properly in the address bar and also the HTTPS config :slight_smile:

Thank you!

error when using domain name (with HTTPS://):

access (but unsecurely via https://IPADDRESS:8087:

@cjh Can you check your config file and see if you have…

'overwrite.cli.url' => 'https://YOURDOMAIN.COM',

thank you,
yes, its in there

@cjh What does your apache2 conf file read? ( /etc/apache2/sites-available/YOUR_DEFAULT.CONF )

ill put here my config files, maybe it helps:

config.php

<?php
$CONFIG = array (
  'instanceid' => 'XXXXX',
  'passwordsalt' => 'XXXXX',
  'secret' => 'XXXXX',
  'trusted_domains' => 
  array (
    0 => 'localhost',
    1 => 'DOMAIN.COM',
    2 => 'PUB IP',
    3 => 'ROUTER IP',
  ),
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'redis' => 
  array (
    'host' => '/var/run/redis/redis.sock',
    'port' => 0,
    'timeout' => 0.0,
    'password' => 'secret',
    'dbindex' => '0',
  ),
  'overwrite.cli.url' => 'https://DOMAIN.COM',
  'datadirectory' => '/mnt/DATADIR',
  'dbtype' => 'mysql',
  'version' => '19.0.1.1',
  'htaccess.RewriteBase' => '/',
  'dbname' => 'XXXXX',
  'dbhost' => 'XXXXX',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'XXXXX',
  'dbpassword' => 'XXXXX',
  'installed' => true,
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 2,
  'app_install_overwrite' => 
  array (
    0 => 'dropit',
    1 => 'twofactor_rcdevsopenotp',
    2 => 'ransomware_detection',
    3 => 'registration',
  ),
  'mail_from_address' => 'XXXXX',
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_domain' => 'XXXXX',
  'mail_smtpsecure' => 'tls',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpauth' => 1,
  'mail_smtphost' => 'XXXXX',
  'mail_smtpport' => 'XXXXX',
  'mail_smtpname' => 'XXXXX',
  'mail_smtppassword' => 'XXXXX',
  'updater.release.channel' => 'stable',
  'session_lifetime' => 300,
  'session_keepalive' => true,
  'trashbin_retention_obligation' => 'D31, D31',
);

Apache conf files:

port 80 config:

<VirtualHost *:80>	
	DocumentRoot "/var/www/html/nextcloud"
	ServerName DOMAIN.COM
	
 ErrorLog ${APACHE_LOG_DIR}/error.log
	CustomLog ${APACHE_LOG_DIR}/access.log combined

Alias /ALIAS "/var/www/html/nextcloud"

	<Directory /var/www/html/nextcloud>
		Options +FollowSymLinks
		AllowOverride All
		
		Satisfy Any
		
		<IfModule mod_dav.c>
			Dav off
		</IfModule>
		
		SetEnv HOME /var/www/html/nextcloud
		SetEnv HTTP_HOME /var/www/html/nextcloud
	</Directory>
	
	RewriteEngine on
	RewriteCond %{SERVER_NAME} =DOMAIN.COM
	RewriteRule ^ https://{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]
	Header always set Content-Security-Policy "upgrade-insecure-requests;"

</VirtualHost>

port 443 config:

<IFModule mod_ssl.c>
<VirtualHost *:443>

ServerName SERVER NAME
ServerAdmin "EMAIL-HERE"
ServerAlias wWWW.DOMAIN.COM

DocumentRoot /var/www/html/nextcloud/

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

SSLCertificateFile /etc/letsencrypt/live/DOMAINCOM/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/DOMAIN.COM/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/DOMAIN.COM/chain.pem
Include /etc/letsencrypt/options-ssl-apache.conf
    
<Directory /var/www/html/nextcloud/>
	Options +FollowSymlinks
	AllowOverride All

	<IfModule mod_dav.c>
		Dav off
	</IfModule>
</Directory>

</VirtualHost>
</IfModule>

@cjh When you edited the above info it made it hard to read… however I don’t know if this is what is causing errors but nextcloud recommends installing to your root webfolder (/var/www/nextcloud) I see from your config that it points to /var/www/html/nextcloud. Here is the install document that shows to place it in /var/www/nextcloud Installation Instructions Again, I don’t know if this is what is causing problems. Can you fix the post to me more legible? Thanks

sorry, im having a hard time posting my code here, im not sure how to quote it properly

In the text area to type either click on the “</>” button after pasting and selecting your text for preformatted text or press “Ctrl+Shift+C” to start that. It will look like this…

Alias /nextcloud "/var/www/nextcloud/"

<Directory /var/www/nextcloud/>
  Options +FollowSymlinks
  AllowOverride All

 <IfModule mod_dav.c>
  Dav off
 </IfModule>

 SetEnv HOME /var/www/nextcloud
 SetEnv HTTP_HOME /var/www/nextcloud

</Directory>

Thank you very much, i did it :slight_smile:

Thank you, i forgot to mention, that i also gave permission to www-data for the folder already. i guess it should be ok

chris

So looking at this more closely, it looks like maybe your port forwarding has an issue. based on what you wrote both 8086 and 8087 are redirecting to http://domain.com.

Do you have a DNS Resolver?

yes and no. so with no-IP i can change the port (because im using their port 80 redirect option) so the domain will be the same, but forward to the port i set it to.

i use no ip also for my dns