apache2

Ответить
ya
^-^
Сообщения: 2747
Зарегистрирован: 16 дек 2021, 19:56

apache2

Сообщение ya »

AH00558

Откройте файл конфигурации Apache (обычно находится по пути /etc/apache2/apache2.conf).
Найдите строку с комментарием "#ServerName www.example.com:80".
Раскомментируйте эту строку (удалите символ '#') и замените www.example.com на доменное имя вашего сервера.
Перезапустите сервер Apache командой: sudo service apache2 restart.
или
systemctl force-reload apache2
ya
^-^
Сообщения: 2747
Зарегистрирован: 16 дек 2021, 19:56

apache2 403

Сообщение ya »

403
/etc/apache2/httpd.conf

Код: Выделить всё

<Directory />
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
        Require all granted
</Directory>
alpine linux
rc-service apache2 reload

debian
systemctl force-reload apache2
ya
^-^
Сообщения: 2747
Зарегистрирован: 16 дек 2021, 19:56

Re: apache2

Сообщение ya »

Автоматическое перенаправление с http на https
/etc/apache2/sites-enabled/000-default.conf

Код: Выделить всё

...
       <Directory /var/www/html/ >
            AllowOverride All
            Require all granted
            Order allow,deny
            allow from all
        </Directory>
...
/var/www/html/.htaccess

Код: Выделить всё

# Включаем поддержку rewrite и определяем правило замены URL
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
# Дополнительные опции не имеющие отношения к rewrite
Options +FollowSymLinks
Options -MultiViews
Allow from All
ya
^-^
Сообщения: 2747
Зарегистрирован: 16 дек 2021, 19:56

Re: apache2

Сообщение ya »

webp
/etc/mime.types

Код: Выделить всё

image/webp	webp
.haccess

Код: Выделить всё

# as lacking in /etc/mime.types of many distributions (debian)
# without it won't work, but probably better off adding it there
AddType image/webp .webp

<IfModule mod_rewrite.c>
  RewriteEngine On

  RewriteCond %{HTTP_ACCEPT} image/webp
  RewriteCond %{REQUEST_FILENAME} -f
  RewriteCond %{REQUEST_FILENAME}.webp -f
  RewriteRule ^/?(.+?)\.(jpe?g|png)$ /$1.$2.webp [NC,T=image/webp,E=EXISTING:1,E=ADDVARY:1,L]

  <IfModule mod_headers.c>
    <FilesMatch "(?i)\.(jpe?g|png)$">
      Header append "Vary" "Accept"
    </FilesMatch>
  </IfModule>
</IfModule>
ya
^-^
Сообщения: 2747
Зарегистрирован: 16 дек 2021, 19:56

Re: apache2

Сообщение ya »

Проверить правильность конфигурации
apachectl -t
apachectl configtest

a2enmod rewrite
a2enmod ssl
a2enmod headers

a2ensite default-ssl.conf

apt install libapache2-mod-security2 libapache-ssllookup-perl

apache2ctl restart

AH01958: SSLStapling: no stapling cache available
добавить в конфиг при этой ошибке

Код: Выделить всё

SSLStaplingCache shmcb:/tmp/stapling_cache(128000)
/etc/apache2/sites-enabled/example.com-ssl.conf

Код: Выделить всё

<IfModule mod_ssl.c>
    SSLStaplingCache shmcb:/tmp/stapling_cache(128000)
    <VirtualHost *:443>

            ServerAdmin webmaster@localhost
            ServerName example.com
            DocumentRoot /var/www

            SSLEngine on

            SSLCertificateFile /etc/apache2/ssl/example.com/apache.crt
            SSLCertificateKeyFile /etc/apache2/ssl/example.com/apache.key

            SSLCACertificateFile /etc/ssl/ca-certs.pem
            SSLUseStapling on
    </VirtualHost>
</IfModule>
ya
^-^
Сообщения: 2747
Зарегистрирован: 16 дек 2021, 19:56

Re: apache2

Сообщение ya »

редирект:

Чтобы сделать редирект с одного сайта на другой и сохранить параметры строки запроса

/etc/apache2/sites-available/ha.sys_redirect.conf

Код: Выделить всё

<VirtualHost *:порт>
        ServerAdmin webmaster@localhost

 RewriteEngine On
 RewriteCond %{HTTPS} off
# RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
 RewriteRule (.*) https://s.hardprivate.com%{REQUEST_URI}

</VirtualHost>

Код: Выделить всё

sudo a2ensite ha.sys_redirect.conf
ya
^-^
Сообщения: 2747
Зарегистрирован: 16 дек 2021, 19:56

Re: apache2

Сообщение ya »

/etc/apache2/ports.conf

Код: Выделить всё

Listen 8170
Listen 8171
/etc/apache2/sites-available/ ha.virsh.conf

Код: Выделить всё

<VirtualHost *:8185>
        ServerAdmin webmaster@localhost
#       ServerName e9.gt:80
#       ServerAlias e9.gt:80 sys.gt:80 192.168.100.9:80
        DocumentRoot /home/gt/html/ha1.virsh/public_html


# RewriteEngine On
# RewriteCond %{HTTPS} off
# RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}


        <Directory />
                Options +SymLinksIfOwnerMatch
                AllowOverride None
                Require all granted
        </Directory>
        <Directory /home/gt/html/ha1.virsh/public_html/>
                Options -Indexes +SymLinksIfOwnerMatch +MultiViews +FollowSymLinks
                AllowOverride All
                Order allow,deny
                allow from all
                Require all granted
                # This directive allows us to have apache2's default start page
                # in /apache2-default/, but still have / go to the right place
                #RedirectMatch ^/$ /apache2-default/
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog /home/gt/html/ha1.virsh/log/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        #LogLevel warn
        LogLevel notice

        CustomLog /home/gt/html/ha1.virsh/log/access.log combined
        ServerSignature On

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options +Indexes +MultiViews +FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>
ya
^-^
Сообщения: 2747
Зарегистрирован: 16 дек 2021, 19:56

Re: apache2

Сообщение ya »

Ответить