Type the URL of my server instead of its public IP.

Solved

Hello everyone :)

This is an Apache owncloud server. I'm using a subdomain.

It is hardcoded, at my place. The box redirects port 80 and 443 to the server (necessary for Letsencrypt). For now, I'm accessing it over HTTP.

Problem: only the server can log in at the URL msrv.**fr, (I don't know if we are allowed to provide the full URL) the local IP of the machine, and the public IP of the server. Other machines: no. Only the public IP.

On the server side: pinging the subdomain URL returns the local IP of the server.

The other machines can't even receive the public IP of the server: "No address associated with this hostname".

Owncloud client works... but only with the public IP and not the subdomain URL.

The other machines at my place can only access the owncloud login by using its public IP: not the subdomain URL. Even Tor (I tried it) reaches the owncloud login interface (provided I force it to accept a URL in HTTP, of course).

File /etc/hosts of the server:

 127.0.0.1 localhost public IP subdomain.fr local IP subdomain.fr local IP 1150-SRV.main-domain.fr 1150-SRV # The following lines are desirable for IPv6 capable hosts # The following lines are desirable for IPv6 capable hosts ::1 localhost ip6-localhost ip6-loopback ff02::1 ip6-allnodes ff02::2 ip6-allrouters

Do you have any leads? I've been struggling with this for a while ;)

Thank you

7 answers

  1. Hello,

    The modifications made in the /etc/hosts file only affect the concerned system. So it's normal that only the machine 1150-SRV can resolve subdomain.fr by the IP.

    If you want it to work for other machines, whether they are other devices on your local network or external users, you need to configure the A record on your domain's public DNS.

    Be careful with this: https://en.wikipedia.org/wiki/Network_address_translation#NAT_hairpinning

    0
    1. Hello, Avion.

      1/ So, there wouldn't be any issue with internal configuration.

      2/ I'll take a look at that on my domain. I believe that when I did it, once, the main domain... had the IP of my box. That bothered me. I'll check it out. I'll get back to you.

      This is what it looks like with my host:

      0
      1. There is no response on your public IP 82.xx.xxx.xxx on ports 80 and 443. You need to review your port forwarding or firewall configuration.

        0
    2. Moderator

      Hello,

      As already mentioned, /etc/hosts only overrides DNS resolutions made on the machine where it is configured. Therefore, you need to register your domain name before hoping to implement HTTPS. Once the name is registered, make sure that your site's name resolves to point to the public IP of your web server. If your web server is hosted on a computer connected to the Internet via a router, the public IP to use is that of your router, which must redirect ports 80 and 443 to the local IP of that computer.

      Regarding letsencrypt, it should normally be quite simple to implement. The following commands should suffice, regardless of whether the apache server listens on port 80, 443, or both.

      Installation:

      sudo apt update sudo apt install certbot python3-certbot-apache sudo a2enmod ssl sudo systemctl restart apache2

      Configuration: At this stage, we only configure the HTTP vhost (we will address HTTPS later). Assuming your site is www.monsite.fr, you can create the file /etc/apache2/sites-available/http.www.monsite.fr.conf here inspired by /usr/share/doc/wordpress/examples/apache.conf

      <VirtualHost *:80> ServerName monsite.fr Redirect permanent / https://www.monsite.fr/ </VirtualHost> <VirtualHost *:80> ServerName www.monsite.fr DocumentRoot /usr/share/wordpress Alias /wp-content "/var/lib/wordpress/wp-content" <Directory /usr/share/wordpress> Options FollowSymLinks AllowOverride Limit Options FileInfo DirectoryIndex index.php Require all granted </Directory> <Directory /var/lib/wordpress/wp-content> Options FollowSymLinks Require all granted </Directory> RewriteEngine on RewriteCond %{SERVER_NAME} =www.monsite.fr RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent] </VirtualHost>

      Remarks:

      • In the example above, it is assumed that the web server is a wordpress installed via debian packages.
      • In this type of installation, the "static" part (common to all wordpress) is stored in /usr/share/doc/wordpress and the part specific to each site in /var/lib/wordpress/wp-content

      Once the HTTP vhost is functional, we prepare the HTTPS vhost using certbot (which will create the required apache configuration itself).

      sudo certbot --apache

      Good luck

      0
      1. Hello.

        @Avion: yes, yes: response to the ping on the public IP, and from everywhere. But not the subdomain.

        @mamiemando: yes, I have a domain name and the server is configured on the subdomain.

        I will review my Vhost. Because the directive

         Redirect permanent / https://www.monsite.fr/

        ... is not supported on my end. I'll provide feedback.

        Thanks everyone ;)

        0
        1. Hello,

          After a new check, I reaffirm: no response from your IP 82.66.xxx.xxx on TCP ports 80 and 443. I'm not talking about ping, which is working fine. I'm talking about establishing communication at the TCP level, necessary before discussing TLS or HTTP.

          0
      2. Can't edit my answer :/

        The modified vhost:

        <VirtualHost *:80> ServerName www.msrv.brusses.fr ServerAlias www.msrv.brusses.fr ServerAdmin webmaster@localhost DocumentRoot /var/www/html/owncloud ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> <Directory /var/www/> Options FollowSymLinks AllowOverride Limit Options FileInfo DirectoryIndex index.php Require all granted RewriteEngine on RewriteCond %{SERVER_NAME} =www.msrv.brusses.fr RewriteRule ^ http://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent] AllowOverride all </Directory>

        So now, I can access the URL via www.msrv.brusses.fr

        0
        1. Good. It's switched to HTTPS with certbot.

          The Vhosts:

          <VirtualHost *:80> ServerName www.msrv.brusses.fr ServerAlias www.msrv.brusses.fr # <<== Useful? ServerAdmin webmaster@localhost DocumentRoot /var/www/html/owncloud ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> <Directory /var/www/> Options FollowSymLinks AllowOverride Limit Options FileInfo DirectoryIndex index.php Require all granted RewriteEngine on RewriteCond %{SERVER_NAME} =www.msrv.brusses.fr RewriteRule ^ http://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent] AllowOverride all </Directory> <VirtualHost *:443> ServerName www.msrv.brusses.fr ServerAlias www.msrv.brusses.fr # <<== Useful? ServerAdmin webmaster@localhost DocumentRoot /var/www/html/owncloud SSLEngine on SSLCertificateFile /etc/letsencrypt/live/msrv.brusses.fr/cert.pem SSLCertificateKeyFile /etc/letsencrypt/live/msrv.brusses.fr/privkey.pem ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> <Directory /var/www/> Options FollowSymLinks AllowOverride Limit Options FileInfo DirectoryIndex index.php Require all granted RewriteEngine on RewriteCond %{SERVER_NAME} =www.msrv.brusses.fr RewriteRule ^ http://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent] AllowOverride all </Directory>

          Yes, but browsers are screaming for help in front of this certificate. As if I weren't on HTTPS.

          I'm going to see how to make Letsencrypt certificates accepted.

          A lead: manually modifying the certificate files?

          0
          1. Moderator

            Hello

            Thank you for looking at this tutorial to post your code snippets. Normally, you don't have to "accept the certificates from letsencrypt": it creates and installs them. If you already have your own certificates, you don't need letsencrypt (see this example).

            Good luck

            0