Перенаправить http на https в apache red hat - PullRequest
0 голосов
/ 01 июня 2018

Я пытаюсь перенаправить http на https. VirtualHost, вот код, который я добавил в httpd-vhosts.conf

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot /var/www/html/dummy-host.example.com
    ServerName apache1.poc
    Redirect / https://apache1.poc
    ServerAlias www.apache1.poc
    ErrorLog /var/log/httpd/dummy-host.example.com-error_log
    CustomLog /var/log/httpd/dummy-host.example.com-access_log common
</VirtualHost>

<VirtualHost *:443>
ServerName apache1.poc
DocumentRoot /var/www/html/dummy-host.example.com
SSLEngine On
# etc...
</VirtualHost>

, но httpd.service не перезапускается, и я получаю следующий статус

httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Fri 2018-06-01 13:20:17 WET; 5min ago
     Docs: man:httpd(8)
           man:apachectl(8)
  Process: 4813 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
  Process: 4811 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
 Main PID: 4811 (code=exited, status=1/FAILURE)

Jun 01 13:20:16 Apache1.POC systemd[1]: Starting The Apache HTTP Server...
Jun 01 13:20:16 Apache1.POC systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
Jun 01 13:20:17 Apache1.POC kill[4813]: kill: cannot find process ""
Jun 01 13:20:17 Apache1.POC systemd[1]: httpd.service: control process exited, code=exited status=1
Jun 01 13:20:17 Apache1.POC systemd[1]: Failed to start The Apache HTTP Server.
Jun 01 13:20:17 Apache1.POC systemd[1]: Unit httpd.service entered failed state.
Jun 01 13:20:17 Apache1.POC systemd[1]: httpd.service failed.

1 Ответ

0 голосов
/ 01 июня 2018

Я нашел решение: в файле httpd-vhosts.conf я должен добавить только:

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot /var/www/html/dummy-host.example.com
    ServerName apache1.poc
    Redirect / https://apache1.poc
    ServerAlias www.apache1.poc
    ErrorLog /var/log/httpd/dummy-host.example.com-error_log
    CustomLog /var/log/httpd/dummy-host.example.com-access_log common
</VirtualHost>

Затем я должен перейти в файл ssl.conf и добавить:

# General setup for the virtual host, inherited from global configuration
    DocumentRoot "/var/www/html/apache1.poc"
    ServerName apache1.poc:443
...