Impossible d'avoir le HTTPS

Résolu
Bonjour, j'ai un site web, mon site était sur le port 80 je l'ai donc changer pour avoir le https mais quand j'écris "https://ipduserv" ça ne fonctionne pas mais quand j'écris "http://ipduserv:443" ça fonctionne... Comment avoir le https merci d'avance :D

10 réponses

  1. Bonjour,

    Il faut configurer ton moteur web a utiliser certains modules, et ajouter des options relatif aux certificats.

    A plus
    0
  2. Salut,

    La premiére étape, c'est le certificat SSL.

    Soit tu généres un certificat dit auto-signé,
    Soit tu généres un certificat par le biais d'une autorité de certification reconnu (gratuit: letsencrypt)

    Ensuite il faut configurer apache pour utiliser les certificats généré.

    Il faut activer le module SSL (encryption)
    sudo a2enmod ssl


    tu rajoutes dans le fichier de conf de ton site un truc du genre :

    <IfModule mod_ssl.c>
    <VirtualHost _default_:443>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    SSLEngine on
    SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
    SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
    <FilesMatch "\.(cgi|shtml|phtml|php)$">
    SSLOptions +StdEnvVars
    </FilesMatch>
    <Directory /usr/lib/cgi-bin>
    SSLOptions +StdEnvVars
    </Directory>
    BrowserMatch "MSIE [2-6]" \
    nokeepalive ssl-unclean-shutdown \
    downgrade-1.0 force-response-1.0
    BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
    </VirtualHost>
    </IfModule>


    Tu modifies pour que ça corresponde à ton nom de domaine, fichier de log etc.

    A plus
    0
    1. J'ajoute ça dans
      apache2.conf
      ?
      0
    2. Et tu redémare apache2.

      sudo systemctl restart apache2.service
      0
    3. Non, tu rajoutes dans /etc/apache2/site-available/tonsiteactuel.conf
      0
    4. dans le fichier de celui qui est activé dans /etc/apache2/site-enabled/
      0


  3. J'ai fait la première commande déja une erreur
    0
    1. dans le 000 ou ssl ?
      0
      1. Remplies les variables en début de fichier :

        DOMAIN="mondomaine.com"
        SITE_PATH="/var/www/html"
        EMAIL="contact@blabla.com"
        CERT="/etc/ssl/${DOMAIN}/public/cert.pem"
        CERT_KEY="/etc/ssl/${DOMAIN}/private/cert.pem""

        cat /etc/apache2/site-available/000-default.conf > /etc/apache2/site-available/${DOMAIN}.conf
        cat << EOF >> /etc/apache2/site-available/${DOMAIN}.conf

        <IfModule mod_ssl.c>
        <VirtualHost _default_:443>
        ServerAdmin ${EMAIL}
        DocumentRoot {SITE_PATH}
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
        SSLEngine on
        SSLCertificateFile ${CERT}
        SSLCertificateKeyFile ${CERT_KEY}

        <FilesMatch "\.(cgi|shtml|phtml|php)$">
        SSLOptions +StdEnvVars
        </FilesMatch>

        <Directory /usr/lib/cgi-bin
        SSLOptions +StdEnvVars
        </Directory>

        BrowserMatch "MSIE [2-6]" \
        nokeepalive ssl-unclean-shutdown \
        downgrade-1.0 force-response-1.0
        BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
        </VirtualHost>
        </IfModule>

        EOF

        rm -Rf /etc/apache2/site-enabled/*

        a2ensite "${DOMAIN}.conf"
        a2enmod ssl

        systemctl restart apache2.service

        0
    2. Donc comme ça :)
      0
      1. Supprime la premiére partie.
        0
      2. par contre ta conf elle dit que ya plus de site en http.

        du coup
        0
    3. Job for apache2.service failed. See 'systemctl status apache2.service' and 'journalctl -xn' for details.



      avril 18 21:52:00 sdon systemd[1]: Starting LSB: Apache2 web server...
      avril 18 21:52:00 sdon apache2[8014]: Starting web server: apache2AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 192.168.1.104. Set the 'ServerName' directive globally t...ress this message
      avril 18 21:52:00 sdon apache2[8014]: (98)Address already in use: AH00072: make_sock: could not bind to address [::]:443
      avril 18 21:52:21 sdon apache2[8014]: failed!
      avril 18 21:52:21 sdon apache2[8014]: The apache2 instance did not start within 20 seconds. Please read the log files to discover problems ... (warning).
      avril 18 21:52:21 sdon systemd[1]: apache2.service: control process exited, code=exited status=1
      avril 18 21:52:21 sdon systemd[1]: Failed to start LSB: Apache2 web server.
      avril 18 21:52:21 sdon systemd[1]: Unit apache2.service entered failed state.
      Hint: Some lines were ellipsized, use -l to show in full.
      root@sdon:/etc/apache2/sites-enabled#
      0
      1. bonjour,
        avril 18 21:52:00 sdon apache2[8014]: (98)Address already in use: AH00072: make_sock: could not bind to address [::]:443
        0
    4. C'est ce fichier sur lequel il y a une erreur ? Je n'ai pas encore ajouter la liste de code que tu me disais car je vois pas dans quelle fichier je devais rentrer ça .


      <VirtualHost *:443>
      # The ServerName directive sets the request scheme, hostname and port that
      # the server uses to identify itself. This is used when creating
      # redirection URLs. In the context of virtual hosts, the ServerName
      # specifies what hostname must appear in the request's Host: header to
      # match this virtual host. For the default virtual host (this file) this
      # value is not decisive as it is used as a last resort host regardless.
      # However, you must set it for any further virtual host explicitly.
      #ServerName www.example.com

      ServerAdmin webmaster@localhost
      DocumentRoot /var/www/html

      # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
      # error, crit, alert, emerg.
      # It is also possible to configure the loglevel for particular
      # modules, e.g.
      #LogLevel info ssl:warn

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

      # For most configuration files from conf-available/, which are
      # enabled or disabled at a global level, it is possible to
      # include a line for only one particular virtual host. For example the
      # following line enables the CGI configuration for this host only
      # after it has been globally disabled with "a2disconf".
      #Include conf-available/serve-cgi-bin.conf
      </VirtualHost>

      <IfModule mod_ssl.c>
      <VirtualHost _default_:443>
      ServerAdmin webmaster@localhost
      DocumentRoot /var/www/html
      ErrorLog ${APACHE_LOG_DIR}/error.log
      CustomLog ${APACHE_LOG_DIR}/access.log combined
      SSLEngine on
      SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
      SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
      <FilesMatch "\.(cgi|shtml|phtml|php)$">
      SSLOptions +StdEnvVars
      </FilesMatch>
      <Directory /usr/lib/cgi-bin>
      SSLOptions +StdEnvVars
      </Directory>
      BrowserMatch "MSIE [2-6]" \
      nokeepalive ssl-unclean-shutdown \
      downgrade-1.0 force-response-1.0
      BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
      </VirtualHost>
      </IfModule>
      0
      1. pour la conf, supprime du premier virtual host au premier /virtualhost
        0
    5. Ca fonctionne j'ai juste remis 80 au fichier 000 default et 80 aussi pour le fichier port.conf :D il ne me reste plus qu'a créer un certificat. par contre comment on retire le 80 car du le site http://monip fonctionne et https://monip fonctionne je voudrais retirer le http://monip
      0
      1. tu peux faire des redirections vers le https via apache.
        ou regarder du coté hsts.
        a plus

        --
        0
    6. J'ai fait mes redirections tout fonctionne juste le firewall qui m'a poser problème merci à toi pour ton aide
      0