I have dockerized symfony app that I access on my machine via 127.0.0.1:8000
it runs via docker compose with an nginx
container and a app
container like so
nginx:
container_name: nginx
image: "${NGINX_IMAGE}"
build: build/nginx
restart: always
env_file: .env
ports:
- "8000:443"
volumes:
- "./build/nginx/build/${MODE}.conf:/etc/nginx/conf.d/default.conf:ro"
- "./build/nginx/build/certs:/etc/nginx/certs"
- "${APP_HOST_DIR}/public:/var/www/app/public:ro"
networks:
- app_network
depends_on:
- app
app:
container_name: app
image: "${APP_IMAGE}"
restart: always
build: build/app
env_file: .env
networks:
- app_network
volumes:
- "${APP_HOST_DIR}:${APP_CONTAINER_DIR}"
the nginx conf
is
server {
listen 80;
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name localhost;
ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt;
ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;
ssl_protocols TLSv1.2 TLSv1.1 TLSv1;
root /usr/share/nginx/html/;
index index.html index.nginx-debian.html;
}
Now I would like to use a separate nginx container to access my website from any device on my network via a custom port like 192.168.1.12:8100
so that from the app point of view it thinks it is coming from local machine and I don't need to modify all symfony settings like trusted hosts, my php and js variables.
at the moment I get untrusted host 192.168.1.12
. I don't want to add a new host because I also have to modify other files to enable a single ip. I would like nginx to proxy somehow.
Here is what I have got:
docker-compose 2
version: "3"
services:
nginx:
container_name: nginx_lan_access
image: "nginx"
build: build/nginx
restart: always
ports:
- 8100:8000
volumes:
- "./default.conf:/etc/nginx/conf.d/default.conf:ro"
default.conf 2
server {
listen 8100 default;
listen [::]:8100 default;
server_name 192.168.1.12;
location / {
proxy_pass https://127.0.0.1:8000;
}
}