Welcome! Log In Create A New Profile

Advanced

Big configuration

Posted by jarl 
Big configuration
January 06, 2022 01:37AM
Hi guys,

I have (all in docker):

1. node in docker 8083:3000 - frontend (I think it is frontend, but may be not)

backend:
2. php no port
3. percona db 8084:3306
4. nodejs 8085:35729 (I am not sure if it is frontend)
5. nginx 8086:80 (seems like to be useless or disturbing)
6. mailhog 8087:8025

and also redirecting nginx outside docker (on the server).

What I need is to proxy with outside nginx to each of the containers IPs. For now it gives me 502 Bad Gateway.

Config is below:

server {
listen 80;
server_name domain.com.dev;

location / {
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://127.0.0.1:8085$1;
}
}

server {
listen 80;
server_name pl.domain.com.dev;

location / {
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://127.0.0.1:8085$1;
}
}

server {
listen 80;
server_name www.domain.com.dev www.domain.eu.dev domain.eu.dev;
return 301 http://domain.com.dev$request_uri;
}

server {
listen 80;
server_name www.domain.pl.dev domain.pl.dev;
return 301 http://pl.domain.com.dev$request_uri;
}



Edited 2 time(s). Last edit at 01/06/2022 01:44AM by jarl.
Re: Big configuration
January 06, 2022 10:51AM
Ok, got it! There was needed much work and some fixes:

server {
listen 80;
server_name
domain.com
;

location / {
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://127.0.0.1:8083$request_uri;
}
}

server {
listen 80;
server_name
pl.domain.com
;

location / {
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://127.0.0.1:8083$request_uri;
}
}

server {
listen 80;
server_name
www.domain.com
www.domain.eu
domain.eu
;
return 301 http://domain.com$request_uri;
}

server {
listen 80;
server_name
www.domain.pl
domain.pl
;
return 301 http://pl.domain.com$request_uri;
}
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 57
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready