0

I'm trying to set up WordPress using docker-compose but WordPress has to work in a separated container with php_fpm, a container for MariaDB, and an Nginx in port 443 redirecting to WordPress if the link was HTTPS://localhost/wordpress but if the link was HTTPS://localhost/ it has to send the request to index.html page on the same container.

but I have a problem with the WordPress URL.

I want when nginx to redirect all the requests coming from https:/localhost/wordpress to WordPress container but when I do it gives me an Access denied. page.

meanwhile when I access https://localhost/wordpress/ (I added a / in the last of the URL) the page work fine

my default.conf file:

server {
    listen                  443 ssl;

    ssl_protocols       TLSv1.3;
    ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt;
      ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;

    root                    /var/www/html;
    index                   index.html;
    # index                   index.html index.htm index.php;
    server_name             _;
    # client_max_body_size    32m;
    # error_page              500 502 503 504  /50x.html;

    # autoindex off;
    # index index.php index.html index.htm index.nginx-debian.html;

    # include /etc/nginx/mime.types;
    location = /50x.html {
            root              /var/lib/nginx/html;
    }
    location / {
    # First attempt to serve request as file, then
    # as directory, then fall back to displaying a 404.
    index index.html;
    # try_files $uri $uri/ /index.php?$args;
    }
  # pass the PHP scripts to FastCGI server listening on wordpress:9000
    location /wordpress {
    # fastcgi_split_path_info ^(.+\.php)(/.+)$;
    # root  /var/www/html/;
    fastcgi_pass 0.0.0.0:9000;
    fastcgi_index index.php;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param SCRIPT_NAME $fastcgi_script_name;
    }
}

NOTE: I Asked the same question on stackoverflow

DarkSide77
  • 101
  • 2
  • `fastcgi_pass 0.0.0.0:9000` looks in my eys wrong,dont xa want to use localhost or a specific IP? – djdomi Oct 10 '21 at 19:47

0 Answers0