I have:
Wordpress + MariaDB inside containers (docker-compose)
Nginx installed into system (not inside container)
I have one more web app that is proxied via nginx, so I don't want to put nginx inside container as all guides recommend. I just need to set proxy or configure it to see Wordpress site from container.
How to configure it to show Wordpress site that is inside container?
My try:
/etc/nginx/sites-enabled/my-site.com
server {
listen 80;
listen [::]:80;
server_name my-site.com;
root /root/my-site.com/wordpress;
index index.php;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ .php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_pass localhost:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location ~ /.ht {
deny all;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
log_not_found off;
access_log off;
allow all;
}
location ~* .(css|gif|ico|jpeg|jpg|js|png)$ {
expires max;
log_not_found off;
}
}
/root/my-site.com/docker-compose.yml
version: '3'
services:
wordpress:
image: wordpress:5.5.0-fpm-alpine
links:
- mariadb:mysql
depends_on:
- mariadb
env_file: .env
environment:
- WORDPRESS_DB_HOST=mariadb:3306
- WORDPRESS_DB_USER=$MYSQL_USER
- WORDPRESS_DB_PASSWORD=$MYSQL_PASSWORD
- WORDPRESS_DB_NAME=my-site_database
ports:
- '9000:9000'
volumes:
- ./wordpress:/var/www/html
networks:
- my-site-network
mariadb:
image: mariadb
env_file: .env
environment:
- MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD
- MYSQL_DATABASE=my-site_database
ports:
- '3306:3306'
volumes:
- ./database:/var/lib/mysql
networks:
- my-site-network
networks:
my-site-network:
driver: bridge
When I open my-site.com I see
404 Not Found
nginx/1.14.0 (Ubuntu)