Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Draft: feat: var BACKUP_SERVER to tag server as backup#2453

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
pini-gh wants to merge1 commit intonginx-proxy:main
base:main
Choose a base branch
Loading
frompini-gh:pini-backup-server
Draft
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletionnginx.tmpl
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -317,8 +317,13 @@ upstream {{ $vpath.upstream }} {
{{- $args = dict "container" $container "path" $path "port" $port }}
{{- template "container_port" $args }}
{{- if $ip }}
{{- $servers = add1 $servers }}
{{- $backup := parseBool (coalesce $container.Env.BACKUP_SERVER "false") }}
{{- if not $backup }}
{{- $servers = add1 $servers }}
server {{ $ip }}:{{ $args.port }};
{{- else }}
server {{ $ip }}:{{ $args.port }} backup;
{{- end }}
{{- end }}
{{- end }}
{{- end }}
Expand Down
14 changes: 14 additions & 0 deletionstest/test_backup-server/test_backup-server.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
import pytest


def test_web1_is_backup(docker_compose, nginxproxy):
for i in range(1, 10):
r = nginxproxy.get("http://web1.nginx-proxy.tld/port")
assert r.status_code == 200
assert r.text == "answer from port 91\n"

def test_web2_is_production(docker_compose, nginxproxy):
for i in range(1, 10):
r = nginxproxy.get("http://web2.nginx-proxy.tld/port")
assert r.status_code == 200
assert r.text == "answer from port 82\n"
44 changes: 44 additions & 0 deletionstest/test_backup-server/test_backup-server.yml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
version: "2"

services:
web1:
image: web
expose:
- "81"
environment:
WEB_PORTS: 81
VIRTUAL_HOST: web1.nginx-proxy.tld
network_mode: "none"

web1_backup:
image: web
expose:
- "91"
environment:
WEB_PORTS: 91
VIRTUAL_HOST: web1.nginx-proxy.tld
BACKUP_SERVER: "true"

web2:
image: web
expose:
- "82"
environment:
WEB_PORTS: 82
VIRTUAL_HOST: web2.nginx-proxy.tld

web2_backup:
image: web
expose:
- "92"
environment:
WEB_PORTS: 92
VIRTUAL_HOST: web2.nginx-proxy.tld
BACKUP_SERVER: "true"

sut:
image: nginxproxy/nginx-proxy:test
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
environment:
HTTPS_METHOD: nohttps

[8]ページ先頭

©2009-2025 Movatter.jp