Why I can't enable gzip compression with Traefik? - docker

I don't have any idea, but I can't enable gzip compression...
My infra is small :
NGINX <-> Traefik <-> internet
docker-compose.yml of nginx
version: "3"
services:
p12:
image: nginx:alpine
volumes:
- ./src:/usr/share/nginx/html
networks:
- traefik
labels:
- traefik.enable=true
- traefik.http.routers.p12.entrypoints=web, websecure
- traefik.http.routers.p12.rule=Host(`p12.sysdraw.fr`)
- traefik.http.routers.p12.middlewares=chain-secure#file
- traefik.http.routers.p12.tls=true
- traefik.http.services.p12.loadbalancer.server.port=80
- traefik.http.routers.p12.tls.certresolver=production
- traefik.http.middlewares.p12.compress=true
restart: unless-stopped
networks:
traefik:
external: true
My rules in Traefik :
chains.yml
http:
middlewares:
chain-secure:
chain:
middlewares:
- middlewares-secure-headers
chain-authelia:
chain:
middlewares:
- middlewares-secure-headers
- authelia#docker
middlewares.yml
http:
middlewares:
test-compress:
compress: {}
middlewares-rate-limit:
rateLimit:
average: 100
burst: 50
middlewares-sslheader:
headers:
customResponseHeaders:
X-Forwarded-Proto:
- "https"
latency-check:
circuitBreaker:
expression: "LatencyAtQuantileMS(50.0) > 100"
test-retry:
retry:
attempts: 4
initialInterval: 100ms
middlewares-secure-headers:
headers:
accessControlAllowMethods:
- GET
- OPTIONS
- PUT
- POST
addVaryHeader: true
#accessControlAllowHeaders:
# - origin
hostsProxyHeaders:
- "X-Forwarded-Host"
#sslRedirect: true # Not used in Version 2.5
# stsSeconds: 63072000 # Uncomment later
stsSeconds: 10
stsIncludeSubdomains: true
stsPreload: true
forceSTSHeader: true
frameDeny: true #overwritten by customFrameOptionsValue
contentTypeNosniff: true
# browserXssFilter: false # Recently became unsafe in a way.
customBrowserXssValue: 0
referrerPolicy: "same-origin"
permissionsPolicy: "camera 'none'; geolocation 'none'; microphone 'none'; payment 'none'; usb 'none'; vr 'none';"
customResponseHeaders:
X-Robots-Tag: "none,noarchive,nosnippet,notranslate,noimageindex,"
server: ""
I have read the documentation of Trafik, for me all is ok, but when I try with curl :
curl -H "Accept-Encoding: gzip" -i https://mywebsite.com 2>/dev/null | head -n 13
HTTP/2 200
accept-ranges: bytes
content-type: text/html
date: Thu, 19 May 2022 11:33:23 GMT
etag: "62091d80-bcb"
last-modified: Sun, 13 Feb 2022 15:02:24 GMT
permissions-policy: camera 'none'; geolocation 'none'; microphone 'none'; payment 'none'; usb 'none'; vr 'none';
referrer-policy: same-origin
strict-transport-security: max-age=10; includeSubDomains; preload
vary: Origin
x-content-type-options: nosniff
x-frame-options: DENY
x-robots-tag: none,noarchive,nosnippet,notranslate,noimageindex,
If you have an idea, share with me :)

Related

Cannot access Docker container from another

Using this docker-compose file:
version: '3'
services:
hello:
image: nginxdemos/hello
ports:
- 7080:80
tool:
image: wbitt/network-multitool
tty: true
networks:
default:
name: test-network
If I curl from the host, it works.
❯ curl -s -o /dev/null -v http://192.168.1.102:7080
* Expire in 0 ms for 6 (transfer 0x8088b0)
* Trying 192.168.1.102...
* TCP_NODELAY set
* Expire in 200 ms for 4 (transfer 0x8088b0)
* Connected to 192.168.1.102 (192.168.1.102) port 7080 (#0)
> GET / HTTP/1.1
> Host: 192.168.1.102:7080
> User-Agent: curl/7.64.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: nginx/1.23.1
< Date: Sun, 10 May 2071 00:06:00 GMT
< Content-Type: text/html
< Transfer-Encoding: chunked
< Connection: keep-alive
< Expires: Sun, 10 May 2071 00:05:59 GMT
< Cache-Control: no-cache
<
{ [6 bytes data]
* Connection #0 to host 192.168.1.102 left intact
If I try to contact another container from within the network, it fails.
❯ docker exec -it $(gdid tool) curl -s -o /dev/null -v http://hello
* Could not resolve host: hello
* Closing connection 0
Is this intended behaviour? I thought networks within the same network (and using docker-compose) are meant to be able to talk by their service name?
I am bringing the containers up with docker-compose up -d

Moodle Docker Web Service working but can not be called from another docker container in the same network

I am running a moodle docker container and one other container to call moodle web service function in a same network. I'm pretty sure I have set up the moodle properly because I can call moodle web service from postman. I am also aware i need to use the container alias of the running moodle container, which in this case is webserver. This is what i have tried
calling http://localhost:8000/webservice/rest/server.php?moodlewsrestformat=json&wstoken=fa4e7222df472b032ca9b4bd6d17595a&wsfunction=core_user_get_users&criteria[0][key]=id&criteria[0][value]=2 from Postman and it return the following response
{
"users": [
{
"id": 2,
"username": "admin",
"firstname": "Admin",
"lastname": "User",
"fullname": "Admin User",
"email": "abc#def.com",
"department": "",
"firstaccess": 1655901976,
"lastaccess": 1655907821,
"auth": "manual",
"suspended": false,
"confirmed": true,
"lang": "en",
"theme": "",
"timezone": "99",
"mailformat": 1,
"description": "",
"descriptionformat": 1,
"profileimageurlsmall": "http://localhost:8000/theme/image.php/boost/core/1655902245/u/f2",
"profileimageurl": "http://localhost:8000/theme/image.php/boost/core/1655902245/u/f1",
"preferences": [
{
"name": "core_message_migrate_data",
"value": "1"
},
{
"name": "auth_manual_passwordupdatetime",
"value": "1655902098"
},
{
"name": "email_bounce_count",
"value": "1"
},
{
"name": "email_send_count",
"value": "1"
},
{
"name": "login_failed_count_since_success",
"value": "0"
},
{
"name": "_lastloaded",
"value": 1655907864
}
]
}
],
"warnings": []
}
but when i try calling the same API from the other container i get a 403 response status, i also tried calling the same API with curl inside the container using curl -v -g 'http://webserver/webservice/rest/server.php?wstoken=fa4e7222df472b032ca9b4bd6d17595a&moodlewsrestformat=json&wsfunction=core_user_get_users&criteria[0][key]=id&criteria[0][value]=2'
with result:
* Trying 172.18.0.8:80...
* Connected to webserver (172.18.0.8) port 80 (#0)
> GET /webservice/rest/server.php?wstoken=fa4e7222df472b032ca9b4bd6d17595a&moodlewsrestformat=json&wsfunction=core_user_get_users&criteria[0][key]=id&criteria[0][value]=2 HTTP/1.1
> Host: webserver
> User-Agent: curl/7.80.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
* HTTP 1.0, assume close after body
< HTTP/1.0 403 Forbidden
< Date: Wed, 22 Jun 2022 14:42:38 GMT
< Server: Apache/2.4.53 (Debian)
< X-Powered-By: PHP/7.4.29
< Content-Length: 0
< Connection: close
< Content-Type: text/html; charset=utf-8
<
* Closing connection 0
so it is clearly connected but somehow still return 403 response, am i missing something? is there another moodle settings i have to tweak?
I am using moodle-docker with added
networks:
default:
name: network_name
external: true
at the end of base.yml file so it could connect to the current project I'm working on which is a Node.js project that will call one of the web service on moodle. Here is the docker-compose.yml which relevant to this question
version: "3.7"
services:
test:
build: .
env_file:
- "./.env"
ports:
- 8085:8085
networks:
- network_name
networks:
network_name:
driver: bridge
name: network_name
this is the result of calling docker logs of the moodle container
172.18.0.1 - - [22/Jun/2022:15:38:27 +0000] "GET /webservice/rest/server.php?wstoken=fa4e7222df472b032ca9b4bd6d17595a&moodlewsrestformat=json&wsfunction=core_user_get_users&criteria[0][key]=id&criteria[0][value]=2 HTTP/1.1" 200 1464 "-" "PostmanRuntime/7.29.0"
[Wed Jun 22 15:38:30.315720 2022] [php7:notice] [pid 22] [client 172.18.0.3:34082] Debugging: The server died because the web services or the REST protocol are not enable in \n* line 39 of /webservice/rest/server.php: call to debugging()\n
172.18.0.3 - - [22/Jun/2022:15:38:30 +0000] "GET /webservice/rest/server.php?wstoken=fa4e7222df472b032ca9b4bd6d17595a&moodlewsrestformat=json&wsfunction=core_user_get_users&criteria[0][key]=id&criteria[0][value]=2 HTTP/1.1" 403 199 "-" "curl/7.80.0"
This error doesn't make any sense to me because i already enabled the web service and the REST protocol on the site administration settings. I also tried to enable web services for mobile devices with no luck so far. I'm also new to moodle development so I might miss something simple so any input is appreciated.
UPDATE:
After restarting the whole docker setup and try to curl from the container again I got this message:
* Trying 172.19.0.8:80...
* Connected to webserver (172.19.0.8) port 80 ()
> GET /webservice/rest/server.php?wstoken=beebce17854eff740ba85ec016542cfe&moodlewsrestformat=json&wsfunction=core_user_get_users&criteria[0][key]=id&criteria[0][value]=2 HTTP/1.1
> Host: webserver
> User-Agent: curl/7.80.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Date: Thu, 23 Jun 2022 07:34:35 GMT
< Server: Apache/2.4.53 (Debian)
< X-Powered-By: PHP/7.4.29
< Vary: Accept-Encoding
< Content-Length: 284
< Content-Type: text/html; charset=UTF-8
<
Install Behat before enabling it, use:
php admin/tool/behat/cli/init.php
<br />
<b>Warning</b>: Cannot modify header information - headers already sent by (output started at /var/www/html/lib/testing/lib.php:169) in <b>/var/www/html/lib/testing/lib.php</b> on line <b>171</b><br />
* Connection #0 to host webserver left intact
After further investigation I found that in config.docker-template.php there is a setting for $CFG->behat_wwwroot which has default value to http://webserver. I am not familiar how to setup testing framework in Moodle so I'm not sure how can I change this.
Now my problem is how to setup the moodle docker to both be exposed from localhost and webserver. Is anyone familiar with this?
Problem
Since you have not mentioned the port cURL tries to connect to port 80 which is the default http port. You can observe it here:
* Connected to webserver (172.18.0.8) port 80 (#0)
Solution
You need to specifically set it as 8000:
Instead of
'http://webserver/webservice/rest/server.php?wstoken=fa4e7222df472b032ca9b4bd6d17595a&moodlewsrestformat=json&wsfunction=core_user_get_users&criteria[0][key]=id&criteria[0][value]=2'
It should be
'http://webserver:8000/webservice/rest/server.php?wstoken=fa4e7222df472b032ca9b4bd6d17595a&moodlewsrestformat=json&wsfunction=core_user_get_users&criteria[0][key]=id&criteria[0][value]=2'
you must use docker-compose to create your network.

How do I run Webpack DevServer and Flask with Docker?

I can't seem to figure out how to run Flask Backend with Webpack Dev Server. The flask routes have a login decorator. Webpack serves my assets but I can't access any backend routes. Client side I prefix the routes with port :8080/someFlaskRoute but that get's redirected to /login which isn't on port 8080?
route decorator:
def login_required(f):
#wraps(f)
def decorated_function(*args, **kwargs):
expiration = session.get('expires', 0)
now = int(time.time())
if expiration == 0 or expiration < now or 'user_id' not in session:
return redirect(url_for('saml_login', _external=True, _scheme='https', next=request.url))
return f(*args, **kwargs)
return decorated_function
docker-compose.yml:
version: "3"
services:
server-dev:
build:
context: ../..
dockerfile: Dockerfile-server-base
network_mode: host
ports:
- 10005:10005
tty: true
stdin_open: true
command: uwsgi --http-socket 0.0.0.0:10005 --http-websockets --module myapp:app --master --processes 4 --enable-threads --honour-stdin --py-autoreload=3 --buffer-size=65535
client-dev:
image: node:12.13.1-slim
network_mode: host
ports:
- 10001:10001
- 3000:3000
command: yarn dev
Webpack Dev Server:
devServer: {
host: '0.0.0.0',
public: '0.0.0.0:0',
port: 10001,
sockPort: 80,
hotOnly: true,
publicPath: '/',
headers: { 'Access-Control-Allow-Origin': '*' }
}
I see the request come in in the logs:
server-dev_1 | [pid: 119|app: 0|req: 1/1] 127.0.0.1 () {52 vars in 1051 bytes} [Wed Jun 10 10:00:03 2020] GET /dashboard/all_data?is_alignment=false&group_id=&hkrgy8asx787tzwnvf2wll => generated 561 bytes in 5 msecs (HTTP/1.1 302) 3 headers in 272 bytes (1 switches on core 0)
But the response header gives me this:
Connection: keep-alive
Content-Length: 561
Content-Type: text/html; charset=utf-8
Date: Wed, 10 Jun 2020 10:00:03 GMT
Location: /login/?next=http%3A%2F%2Fmysite.com%2Fdashboard%2Fall_data
Generated-By: dev-machine
Server: nginx
nginx config:
upstream flask_upstream {
server localhost:10005;
}
server {
listen 8080;
server_name ~^(?!api).*.mysite.com;
location / {
proxy_pass http://flask_upstream;
proxy_set_header X-Forwarded-Protocol ssl;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
include /etc/nginx/conf.d/proxy.conf;
set $upstream_name flask_upstream;
}
}

Docker somehow modify connection?

I have a curl request to a SharePoint. This curl in not changed form is working on the HOST with Ubuntu and it is not working correctly on the docker container with ubuntu... The problem is that the request is quite long and if run from the container I receive 401 Unauthorized after exactly 50 seconds. On host, it is working fine. If the request is shorter than 50 seconds then it works on both systems. Any ideas?
The curl is:
curl -k -v --http1.1 --ntlm --negotiate -u john:ABCabc123 -H "Content-type:application/json" -H "X-RequestDigest:0xD014B3ADC4C93DC83F204FAA953830CDD534A6DB13ECAE0CF40F4E7ECAA6E45E877B94D0F8A214940E5BFE5B5BA82AE9CAFA5974345A0EA96FEA9C91932AB5EB,13 Aug 2019 10:42:21 -0000" -d '{"query":{"ViewXml":"<View><Query></Query></View>"}}' -X POST "https://myapp/coll/9630bbe88ab246cd993f0085204a796a/_api/Web/Lists/GetByTitle('1')/GetItems?$select=Id,ContentType/Name&$expand=ContentType"
And wrong response after 50 seconds:
TTP/1.1 401 Unauthorized
< Server: Microsoft-IIS/10.0
< WWW-Authenticate: NTLM TlRMTVNTUAACAAAACQAJADgAAAAGgokC5MF+J9Y9IxEAAAAAAAAAAKoAqgBBAAAACgA5OAAAAA9HUkVEU1BERVYCABIARwBSAEUARABTAFAARABFAFYAAQASAFMAUAAxADYARABFAFYAMQA5AAQAGgBnAHIAZQBkAHMAcABkAGUAdgAuAGwAbwBjAAMALgBzAHAAMQA2AGQAZQB2ADEAOQAuAGcAcgBlAGQAcwBwAGQAZQB2AC4AbABvAGMABQAaAGcAcgBlAGQAcwBwAGQAZQB2AC4AbABvAGMABwAIAL57xWXGUdUBAAAAAA==
< SPRequestGuid: 04cdf99e-219a-f0fb-63ce-01c13ef289a5
< request-id: 04cdf99e-219a-f0fb-63ce-01c13ef289a5
< X-FRAME-OPTIONS: SAMEORIGIN
< SPRequestDuration: 3
< SPIisLatency: 0
< X-Powered-By: ASP.NET
< MicrosoftSharePointTeamServices: 16.0.0.4783
< X-Content-Type-Options: nosniff
< X-MS-InvokeApp: 1; RequireReadOnly
< Date: Tue, 13 Aug 2019 11:01:02 GMT
< Content-Length: 0
Additional info:
Some parts of docker file:
FROM mcr.microsoft.com/dotnet/core/aspnet:2.2.6-bionic AS runtime
ENTRYPOINT ["dotnet", "Core.API.dll"]
Some parts of docker compose:
version: "3.7"
services:
core_api:
container_name: core_debug
network_mode: host
build:
dockerfile: ./Dockerfile.lnx
network: host
image: core_api
env_file:
- Deployment/LocalVM/sonar.env
ports:
- "80:80"
- "44364:80"
- "8080:80"
tmpfs:
- /run

Nginx Reverse Proxy not redirecting?

Update
The details in this question are getting long, but I think it narrows down to this:
For some reason the host name matters to Nginx when it's trying to figure out whether to proxy the request. If the host name is set to git.example.com the request does not seem to go through, but if it's set to 203.0.113.2 then it goes through. Why does the host name matter?
Filed an issue with Nginx here
And docker compose
Start of original question
When I type in the IP address of the reverse proxy directly into my browser bar, it does perform the redirect.
When using a URL that is resolved via the /etc/hosts entry 203.0.113.2 git.example.com the "Welcome to Ngnix page" is shown. Any ideas? This is the configuration:
server {
listen 203.0.113.2:80 default_server;
server_name 203.0.113.2 git.example.com;
proxy_set_header X-Real-IP $remote_addr; # pass on real client IP
location / {
proxy_pass http://203.0.113.1:3000;
}
}
This is the docker-compose.yml file that is used to launch the whole thing:
version: '3'
services:
gogs-nginx:
build: ./proxy
ports:
- "80:80"
networks:
mk1net:
ipv4_address: 203.0.113.2
gogs:
image: gogs/gogs
ports:
- "3000:3000"
volumes:
- gogs-data:/data
networks:
mk1net:
ipv4_address: 203.0.113.3
volumes:
gogs-data:
external: true
networks:
mk1net:
ipam:
config:
- subnet: 203.0.113.0/24
One interesting thing is that I can navigate to for example:
http://203.0.113.2/issues
The log for the above URL is:
gogs-nginx_1 | 203.0.113.1 - - [07/Oct/2018:11:28:06 +0000] "GET / HTTP/1.1" 200 38825 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36" "-"
If I then change 203.0.113.2 with git.example.com (So that the url ends up being git.example.com I get Nginxs "404 not found" page, and the log says:
gogs-nginx_1 | 2018/10/07 11:31:34 [error] 8#8: *10 open() "/usr/share/nginx/html/issues" failed (2: No such file or directory), client: 203.0.113.1, server: localhost, request: "GET /issues HTTP/1.1", host: "git.example.com"
If I only use http://git.example.com as the URL I get the NGINX welcome page, and the following log:
gogs-nginx_1 | 203.0.113.1 - - [07/Oct/2018:11:34:39 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36" "-"
It looks like Nginx understands that the request is for the proxy because it logs the IP of the proxy, but it does not redirect to the proxy and returns a 304 ...
Using Curl to perform requests
Using curl with a host name parameter that targets the proxy like this:
curl -H 'Host: git.example.com' -si http://203.0.113.2
Results in the Nginx welcome page:
ole#mki:~/Gogs/.gogs/docker$ curl -H 'Host: git.example.com' -si http://203.0.113.2
HTTP/1.1 200 OK
Server: nginx/1.15.1
Date: Sun, 07 Oct 2018 17:09:11 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Tue, 03 Jul 2018 13:27:08 GMT
Connection: keep-alive
ETag: "5b3b79ac-264"
Accept-Ranges: bytes
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
nginx.org.<br/>
Commercial support is available at
nginx.com.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
But if I change the host name to the ip address like this:
Using curl with a host name parameter that targets the proxy like this:
curl -H 'Host: 203.0.113.2' -si http://203.0.113.2
Then the proxy works as it should:
ole#mki:~/Gogs/.gogs/docker$ curl -H 'Host: 203.0.113.2' -si http://203.0.113.2
HTTP/1.1 302 Found
Server: nginx/1.15.1
Date: Sun, 07 Oct 2018 17:14:46 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 34
Connection: keep-alive
Location: /user/login
Set-Cookie: lang=en-US; Path=/; Max-Age=2147483647
Set-Cookie: i_like_gogits=845bb09d69587b81; Path=/; HttpOnly
Set-Cookie: _csrf=neGgBfG4LdOcdrdeA0snHjVGz4s6MTUzODkzMjQ4NjE5MzEzNzI3OQ%3D%3D; Path=/; Expires=Mon, 08 Oct 2018 17:14:46 GMT; HttpOnly
Set-Cookie: redirect_to=%252F; Path=/
Found.
I am sorry, I failed to realize what's happening on your side because the information is sometimes confusing and sometimes incomplete. But Stackoverflow provides a great explanation on what is considered a good question: How to create a Minimal, Complete, and Verifiable example and so I have just tried to implement a minimal example of a system you are likely going to build.
Below I am providing all the files and will show you a test run as well.
File #1: docker-compose.yml
gogs:
image: gogs/gogs
web:
build: .
ports:
- 8000:80
links:
- gogs
I have outdated Docker at my computer and I do not want to bother with Docker networking, so I have just linked both containers using Docker links. This is the most important part and the link will ensure that (1) our web container depends on gogs; (2) we are able to reference gogs IP from inside web as just gogs. Docker will resolve the name to an IP assigned to the container.
Since I want a minimal example, I've skipped everything else as irrelevant. For example, volume.
File #2: Dockerfile
Newer Compose versions support config options specified right in docker-compose.yml, but I need a custom Dockerfile instead. It's trivial:
FROM nginx:stable-alpine
COPY gogs.conf /etc/nginx/conf.d
File #3: gogs.conf
And finally we need Nginx configuration for proxy:
server {
listen 80 default_server;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
location / {
proxy_pass http://gogs:3000;
}
}
You may notice here we are referring another container simply by name gogs and we need to know what port number it is exposes. We know: 3000.
Running
$ docker-compose build
$ docker-compose up
It's up and running:
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1f74293df630 g_web "nginx -g 'daemon off" 2 minutes ago Up 26 seconds 0.0.0.0:8000->80/tcp g_web_1
dfa2dbaa6074 gogs/gogs "/app/gogs/docker/sta" 2 minutes ago Up 26 seconds 22/tcp, 3000/tcp g_gogs_1
web container is exposed to the world at port number 8000.
Tests
by IP
Let's request it by IP:
$ curl -si http://192.168.99.100:8000/
HTTP/1.1 302 Found
Server: nginx/1.14.0
Date: Sun, 07 Oct 2018 15:13:55 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 31
Connection: keep-alive
Location: /install
Set-Cookie: lang=en-US; Path=/; Max-Age=2147483647
Set-Cookie: i_like_gogits=50411f542e2ae8f8; Path=/; HttpOnly
Set-Cookie: _csrf=ZJxRPqnqayIbpAYgZ22zrPIOaSo6MTUzODkyNTIzNTQ2NTg5MDE1NA%3D%3D; Path=/; Expires=Mon, 08 Oct 2018 15:13:55 GMT; HttpOnly
Found.
Corresponding log file:
web_1 | 192.168.99.1 - - [07/Oct/2018:15:14:24 +0000] "GET / HTTP/1.1" 302 31 "-" "curl/7.61.1" "-"
gogs_1 | [Macaron] 2018-10-07 15:14:24: Started GET / for 192.168.99.1
gogs_1 | [Macaron] 2018-10-07 15:14:24: Completed GET / 302 Found in 199.519µs
gogs_1 | 2018/10/07 15:14:24 [TRACE] Session ID: 38d06d393a9e9d21
gogs_1 | 2018/10/07 15:14:24 [TRACE] CSRF Token: Xth986dFWhhj8w8vBdIqRZu4SbI6MTUzODkyNTI2NDYxMDYzNzAyNA==
I can see from the log that (1) both containers work and they were used to process the request; (2) 192.168.99.1 is my host's IP address, which means "gogs" successfully gets a real request IP via X-Forwarded-For.
by domain name
OK, let's request using a domain name:
$ curl -H 'Host: g.example.com' -si http://192.168.99.100:8000/
Trust me, this is just sufficient. Host is an HTTP protocol header to pass domain name. And any browser will do the same under the hood.
and the corresponding log file is --
gogs_1 | [Macaron] 2018-10-07 15:32:49: Started GET / for 192.168.99.1
gogs_1 | [Macaron] 2018-10-07 15:32:49: Completed GET / 302 Found in 618.701µs
gogs_1 | 2018/10/07 15:32:49 [TRACE] Session ID: 81f64d97e9c3dd1e
gogs_1 | 2018/10/07 15:32:49 [TRACE] CSRF Token: X5QyHM4LMIfn8OSJD1gwSSEyXV46MTUzODkyNjM2OTgyODQyMjExMA==
web_1 | 192.168.99.1 - - [07/Oct/2018:15:32:49 +0000] "GET / HTTP/1.1" 302 31 "-" "curl/7.61.1" "-"
No changes, everything works as expected.

Resources