Search code examples
djangoapachenginxmod-wsgiplesk

Django + Plesk + Apache - Forbidden 403 on certain urls but 404's show application is running...?


Disclaimer: this may well be a duplicated answer. However, I'm very tried, frustrated and lost on this. Happy for anyone to point me in the right direction! :)

Issue:

Using Plesk Onyx, I'm trying to deploy my Django application via Apache.

I'm seeing Forbidden 403 on certain urls but 404's on others that throw a 404. So, the Django application is "working" - but somewhere my permissions have hit a brick wall...

So - navigating to https://api.winduplordvexxos.com/admin/ or https://api.winduplordvexxos.com hits a complete 403 brick wall.

However, when navigating to any 404 I see the Django 404 url lookup error page:

Django 404 Page Not Found

This is progress - the wsgi process is there working somewhere.

My http and https directives are as follows, along with blank nginx directives:

Apache Conguration/Directives

The above configuration works fine for manual deployment to a server without nginx installed...

Seeing this page gives me so much hope! :D I'm almost there...

N.B.: mod_wsgi is installed. I'm running Ubuntu 16.04. My server has Plesk Onyx installed. Nginx is getting in the way, etc etc

So, my theoretical solution is somehow maybe involving nginx? Turning it off? :D

Or perhaps giving it permission to work in conjunction with Apache...?

UPDATE: If useful, here is my nginx conf file for the domain:

#ATTENTION!
#
#DO NOT MODIFY THIS FILE BECAUSE IT WAS GENERATED AUTOMATICALLY,
#SO ALL YOUR CHANGES WILL BE LOST THE NEXT TIME THE FILE IS GENERATED.

server {
        listen 104.248.238.218:443 ssl http2;

        server_name api.winduplordvexxos.com;
        server_name www.api.winduplordvexxos.com;
        server_name ipv4.api.winduplordvexxos.com;

        ssl_certificate             /opt/psa/var/certificates/scfmLBLuq;
        ssl_certificate_key         /opt/psa/var/certificates/scfmLBLuq;
        ssl_client_certificate      /opt/psa/var/certificates/scfFzGCFF;

        client_max_body_size 128m;

        root "/var/www/vhosts/winduplordvexxos.com/api.winduplordvexxos.com/public";
        access_log "/var/www/vhosts/system/api.winduplordvexxos.com/logs/proxy_access_ssl_log";
        error_log "/var/www/vhosts/system/api.winduplordvexxos.com/logs/proxy_error_log";

        #extension letsencrypt begin
        location /.well-known/acme-challenge/ {
                root /var/www/vhosts/default/htdocs;

                types { }
                default_type text/plain;

                satisfy any;
                auth_basic off;
                allow all;

                location ~ ^/\.well-known/acme-challenge.*/\. {
                        deny all;
                }
        }
        #extension letsencrypt end

        location / {
                proxy_pass https://104.248.238.218:7081;
                proxy_set_header Host             $host;
                proxy_set_header X-Real-IP        $remote_addr;
                proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
                access_log off;

        }

        location ~ ^/(plesk-stat|awstats-icon|webstat|webstat-ssl|ftpstat|anon_ftpstat) {
                proxy_pass https://104.248.238.218:7081;
                proxy_set_header Host             $host;
                proxy_set_header X-Real-IP        $remote_addr;
                proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
                access_log off;

        }

        location ~ ^/~(.+?)(/.*?\.php)(/.*)?$ {
                alias /var/www/vhosts/winduplordvexxos.com/web_users/$1/$2;
                fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
                fastcgi_param PATH_INFO $fastcgi_path_info;
                fastcgi_pass "unix:///var/www/vhosts/system/api.winduplordvexxos.com/php-fpm.sock";
                include /etc/nginx/fastcgi.conf;

        }

        location ~ ^/~(.+?)(/.*)?$ {
                proxy_pass https://104.248.238.218:7081;
                proxy_set_header Host             $host;
                proxy_set_header X-Real-IP        $remote_addr;
                proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
                access_log off;

        }

        location ~ \.php(/.*)?$ {
                fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
                fastcgi_param PATH_INFO $fastcgi_path_info;
                fastcgi_pass "unix:///var/www/vhosts/system/api.winduplordvexxos.com/php-fpm.sock";
                include /etc/nginx/fastcgi.conf;

        }

        location ~ /$ {
                index "index.html" "index.cgi" "index.pl" "index.php" "index.xhtml" "index.htm" "index.shtml";
        }

        add_header X-Powered-By PleskLin;

        include "/var/www/vhosts/system/api.winduplordvexxos.com/conf/vhost_nginx.conf";
}

server {
        listen 104.248.238.218:80;

        server_name api.winduplordvexxos.com;
        server_name www.api.winduplordvexxos.com;
        server_name ipv4.api.winduplordvexxos.com;

        client_max_body_size 128m;

        return 301 https://$host$request_uri;
}

Solution

  • In Plesk Onyx , I needed to navigate to the following:

    • Go to "Tools & Settings" and then onto "Services Management"

    • Under "Services Management" locate "Reverse Proxy Server (nginx)"

    • Once located, simply stop the "Reverse Proxy Server (nginx)" service.

    Simple when you know how! (Complete luck/chance/desperation!)