@matveyboyko

Как настроить nginx+apache2 на Debian 8?

Приветствую!
Имеется домашний сервер по адресу: http://sgus.ddns.net:61840
Порт 61840 проброшен на 80-й.
Стоит apache и сайт работает.
netstat -tulpn | grep :8
tcp6       0      0 :::80                   :::*                    LISTEN      3350/apache2

Возникла необходимость в целях безопасности и производительности в качестве fron-end'а к апачу поставить nginx.
Мои действия.
1. Перевел апач на прослушку 81-го порта:
nano /etc/apache2/ports.conf
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default.conf

NameVirtualHost 127.0.0.1:81
Listen 81

<IfModule ssl_module>
        Listen 443
</IfModule>

<IfModule mod_gnutls.c>
        Listen 443
</IfModule>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

netstat -tulpn | grep :8
tcp6       0      0 :::81                   :::*                    LISTEN      3471/apache2

2. Установил nginx, кот. по-умолчанию слушает 80-й порт.
3. В директории cd /etc/nginx/sites-available создал файл html.conf:
server {
    listen *:80;
    server_name html;

    location / {
        proxy_pass http://127.0.0.1:81/;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_connect_timeout 120;
        proxy_send_timeout 120;
        proxy_read_timeout 180;
    }

    location ~* \.(jpg|jpeg|gif|png|ico|css|bmp|swf|js|html|txt)$ {
        root /var/www/html; 
    }
}

4. Собственно, как видно из конфига, в директории /var/www/html лежит проинсталенный и развернутый сайт на Prestashop (при голом апаче нормально работает).
5. Содержимое файла /etc/apache2/sites-available/000-default.conf:
<VirtualHost 127.0.0.1:81>
        # 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>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

6. Nginx и apache рестартованы.
Если ничего не забыл, то вроде все.
Получаю ошибку: "403 Forbidden
nginx/1.6.2".
Направьте в нужное русло, что упустил или сделал не так?
  • Вопрос задан
  • 417 просмотров
Пригласить эксперта
Ответы на вопрос 1
chupasaurus
@chupasaurus
Сею рефлекторное, злое, временное
Ванга-мод: доступ к файлам в /var/www/html/ у nginx или apache отсутствует. Точная причина в логах nginx.
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы