M
M
Maxim Grechushnikov2019-03-21 01:10:38
Apache HTTP Server
Maxim Grechushnikov, 2019-03-21 01:10:38

HTTP->HTTPS why looping?

#site.conf
<VirtualHost *:80>
        ServerName site.ru
        ServerAlias www.site.ru
 
        ServerAdmin [email protected]
        DocumentRoot /var/www/html/frontend/web
 
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
 
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.site.ru [OR]
RewriteCond %{SERVER_NAME} =site.ru
#делал также RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

#ssl-site.conf
<IfModule mod_ssl.c>
<VirtualHost *:443>
        ServerName site.ru
        ServerAlias www.site.ru
 
        ServerAdmin [email protected]
        DocumentRoot /var/www/html/frontend/web
  
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
  
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/site.ru/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/site.ru/privkey.pem
</VirtualHost>
</IfModule>

[email protected]:/etc/apache2/sites-enabled# ls -la
total 8
drwxr-xr-x 2 root root 4096 Mar 20 22:13 .
drwxr-xr-x 8 root root 4096 Mar 20 20:52 ..
lrwxrwxrwx 1 root root   30 Mar 20 21:57 site.conf -> ../sites-available/site.conf
lrwxrwxrwx 1 root root   34 Mar 20 21:57 ssl-site.conf -> ../sites-available/ssl-site.conf

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question