Wordpress installed in docker does not load css when visited in domain

Asked 1 years ago, Updated 1 years ago, 68 views

Background:

I installed Ubuntu 18.04 on the raspies and installed wordpress on docker.

Reference site where wordpress is installed in docker
https://docs.docker.com/samples/wordpress/

After installing it, the wifi at home is connected well, and the css is loaded well.

Next, I linked to the domain in Nginx, but when I visited from the domain, I got the following error:

/wp-admin/install.php?step=1:8 GET http://localhost:8111/wp-includes/css/dashicons.min.css?ver=5.9net::ERR_CONNECTION_REFUSED
/wp-admin/install.php?step=1:9 GET http://localhost:8111/wp-includes/cs/buttons.min.css?ver=5.9net::ERR_CONNECTION_REFUSED

In other words, you can find localhost.

This may be due to Nginx configuration.
Here is a simple configuration:

server{
        listen80;
        listen [::]:80;

        server_name my.domain.com;

        location / {
                proxy_pass http://localhost:8111;
        }
}

How can I fix it?

ubuntu docker wordpress nginx

2022-09-30 12:09

2 Answers

Assume you are on the installation page from the message in the questionnaire.

If you use proxy_pass on nginx, the request will be overwritten with the hostname used in proxy_pass, as pointed out in the other answer.

If you want to continue with the Host header from the original request, proxy_set_header will hand over the original request header.

proxy_set_header Host $proxy_host;

wordpress:latest operates PHP with Apache HTTPD, but php-fpm is often preferred when used with nginx (if desired).


2022-09-30 12:09

The reason seems to be that you specified localhost in the following description.

 location/{
    proxy_pass http://localhost:8111;
}


2022-09-30 12:09

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.