Below is my nginx.conf
events {
}
http {
error_log /etc/nginx/error_log.log debug;
client_max_body_size 20m;
proxy_cache_path /etc/nginx/cache keys_zone=one:500m max_size=1000m;
server {
listen 80;
server_name example.org;
client_max_body_size 1000M;
location / {
client_max_body_size 1000M;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
return 301 https://$host$request_uri;
}
location /.well-known/acme-challenge/ {
client_max_body_size 1000M;
root /var/www/certbot;
}
}
server {
listen 80;
server_name www.example.org;
client_max_body_size 1000M;
location / {
client_max_body_size 1000M;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
return 301 https://$host$request_uri;
}
location /.well-known/acme-challenge/ {
client_max_body_size 1000M;
root /var/www/certbot;
}
}
server {
listen 80;
server_name webmin.example.org;
client_max_body_size 1000M;
location / {
client_max_body_size 1000M;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Host webmin.example.org;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
return 301 https://$host$request_uri;
}
location /.well-known/acme-challenge/ {
client_max_body_size 1000M;
root /var/www/certbot;
}
}
server {
listen 80;
server_name portainer.example.org;
client_max_body_size 1000M;
location / {
client_max_body_size 1000M;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Host webmin.example.org;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
return 301 https://$host$request_uri;
}
location /.well-known/acme-challenge/ {
client_max_body_size 1000M;
root /var/www/certbot;
}
}
server {
listen 80;
server_name pgadmin.example.org;
client_max_body_size 1000M;
location / {
client_max_body_size 1000M;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Host pgadmin.example.org;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
return 301 https://$host$request_uri;
}
location /.well-known/acme-challenge/ {
client_max_body_size 1000M;
root /var/www/certbot;
}
}
server {
listen 443 ssl;
server_name example.org;
client_max_body_size 1000M;
ssl_certificate /etc/letsencrypt/live/example.org/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.org/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
location / {
client_max_body_size 1000M;
proxy_pass http://192.168.0.1:7003;
}
}
server {
listen 443 ssl;
server_name www.example.org;
client_max_body_size 1000M;
ssl_certificate /etc/letsencrypt/live/example.org/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.org/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
location / {
client_max_body_size 1000M;
proxy_pass http://192.168.0.1:7003;
}
}
server {
listen 443 ssl;
server_name webmin.example.org;
client_max_body_size 1000M;
ssl_certificate /etc/letsencrypt/live/example.org/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.org/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
location / {
client_max_body_size 1000M;
proxy_pass http://192.168.0.1:10000;
}
}
server {
listen 443 ssl;
server_name portainer.example.org;
client_max_body_size 1000M;
ssl_certificate /etc/letsencrypt/live/example.org/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.org/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
location / {
client_max_body_size 1000M;
proxy_pass http://192.168.0.1:7001;
}
}
server {
listen 443 ssl;
server_name pgadmin.example.org;
client_max_body_size 1000M;
ssl_certificate /etc/letsencrypt/live/example.org/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.org/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
location / {
client_max_body_size 1000M;
proxy_pass http://192.168.0.1:7002;
}
}
}
below is my docker-compose.yml for nginx
version: "3"
services:
nginx:
image: nginx
restart: always
ports:
- 80:80
- 443:443
volumes:
- "./nginx.conf:/etc/nginx/nginx.conf"
- ./data/certbot/conf:/etc/letsencrypt
- ./data/certbot/www:/var/www/certbot
command: "/bin/sh -c 'while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\"'"
networks:
- dockernet
certbot:
image: certbot/certbot
volumes:
- ./data/certbot/conf:/etc/letsencrypt
- ./data/certbot/www:/var/www/certbot
entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"
networks:
- dockernet
networks:
dockernet:
external: true
below is my docker-compose.yml for wordpress
version: "3"
services:
db:
build: ./db
restart: always
volumes:
- ${HOME}/wordpress/dbvolume:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: password
pgadmin:
restart: on-failure:10
image: phpmyadmin/phpmyadmin:edge
environment:
PMA_HOST: db
ports:
- 7002:80
depends_on:
- db
web:
build: ./web
depends_on:
- db
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: root
WORDPRESS_DB_PASSWORD: password
WORDPRESS_DB_NAME: databasename
volumes:
- ${HOME}/wordpress/public_html/:/var/www/html/
ports:
- 7003:80
So when I load https://example.org
my site loads without any problem.
BUT when I load https://example.org/something/
I'm getting redirected to https://192.168.0.1:7003/something/
siteurl is example.org in database. I even added define( 'WP_HOME', 'example.org' ); define( 'WP_SITEURL', 'example.org' ); to wp-config.php
What am I doing wrong here ? Main domain works but why I can't load any other page ? I'm using google compute engine to setup my site.