1 2 3 4 5 6 7 8 9 10 11 12 13 | server {
listen {{ SRC_SERVER_PUB_IP }}:80;
servern_name {{ FQDN }} www.{{ FQDN }}
location / {
proxy_pass http://{{ SRC_SERVER_LOCAL_IP }}:80/;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
} |
1 2 3 4 5 6 7 8 9 | #! /usr/bin/env bash
SRC_SERVER_PUB_IP=192.168.0.100
SRC_SERVER_LOCAL_IP=127.0.0.1
FQDN=example.com
sed -e "s/{{ SRC_SERVER_PUB_IP }}/${SRC_SERVER_PUB_IP}/"\
-e "s/{{ SRC_SERVER_LOCAL_IP }}/${SRC_SERVER_LOCAL_IP}/"\
-e "s/{{ FQDN }}/${FQDN}/g" < 0.nginx_proxy_conf.tpl > proxy.nginx.conf |
1 2 3 4 5 6 7 8 9 10 11 12 13 | server {
listen 192.168.0.100:80;
servern_name example.com www.example.com
location / {
proxy_pass http://127.0.0.1:80/;
proxy_redirect off;
proxy_set_header Host ;
proxy_set_header X-Real-IP ;
proxy_set_header X-Forwarded-For ;
}
} |
1 2 3 4 5 6 7 8 9 10 11 12 13 | server {
listen ${SRC_SERVER_PUB_IP}:80;
servern_name ${FQDN} www.${FQDN}
location / {
proxy_pass http://${SRC_SERVER_LOCAL_IP}:80/;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
} |
1 2 3 4 5 6 7 8 9 10 11 12 13 | #! /usr/bin/env bash
# render a template configuration file
# expand variables + preserve formatting
render_template() {
eval "echo \"$(cat $1)\""
}
SRC_SERVER_PUB_IP=192.168.0.100
SRC_SERVER_LOCAL_IP=127.0.0.1
FQDN=example.com
render_template 1.nginx_proxy_conf.tpl > proxy.nginx.conf |