Как устранить ошибку 403 при доступе к сайту с django? - PullRequest
0 голосов
/ 29 апреля 2020

Сайт работает на vps с CentOS7. Сервер использует последнюю версию httpd (apache2 для centos) и mod-wsgi. Сайт был создан с django.

Каждый раз, когда я пытаюсь получить доступ к сайту либо через ip, я получаю 403 запрещенную ошибку, и когда я пробую домен сайта, я получаю ошибку тайм-аута.

sudo status httpd возвращает

   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: active (running) since Wed 2020-04-29 01:44:44 MST; 1s ago
     Docs: man:httpd(8)
           man:apachectl(8)
  Process: 3698 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=0/SUCCESS)
  Process: 29778 ExecReload=/usr/sbin/httpd $OPTIONS -k graceful (code=exited, status=0/SUCCESS)
 Main PID: 3703 (httpd)
   Status: "Processing requests..."
   CGroup: /system.slice/httpd.service
           ├─3703 /usr/sbin/httpd -DFOREGROUND
           ├─3704 /usr/sbin/httpd -DFOREGROUND
           ├─3705 /usr/sbin/httpd -DFOREGROUND
           ├─3706 /usr/sbin/httpd -DFOREGROUND
           ├─3707 /usr/sbin/httpd -DFOREGROUND
           ├─3708 /usr/sbin/httpd -DFOREGROUND
           └─3709 /usr/sbin/httpd -DFOREGROUND

Это файл конфигурации моих сайтов, хранящийся в /etc/httpd/conf.d/mysite.com.conf

    # 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 mysite.com
    ServerAlias www.mysite.com

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    #DocumentRoot /var/www/mysite.com/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
    ErrorLog /var/www/mysite.com/log/error.log
    #CustomLog ${APACHE_LOG_DIR}/access.log combined
    CustomLog /var/www/mysite.com/log/requests.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

  Alias /static /home/user/mysite/static
  <Directory /home/user/mysite/static>
    Require all granted
  </Directory>

  Alias /media /home/user/mysite/media
  <Directory /home/user/mysite/media>
    Require all granted
  </Directory>

  <Directory /home/user/mysite/mysite>
    <Files wsgi.py>
      Require all granted
    </Files>
  </Directory>

  WSGIScriptAlias / /home/user/mysite/mysite/wsgi.py
  WSGIDaemonProcess django_app python-path=/home/user/mysite:/home/user/mysite/venv/lib/python3.6/site-packages
  #WSGIDaemonProcess django_app python-path=/home/user/mysite python-home=/home/user/mysite/venv
  WSGIProcessGroup django_app

</VirtualHost>

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