Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adopt the haproxy config examples to the HAProxy 2.x version #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
9 changes: 5 additions & 4 deletions proxyexamples/haproxy/haproxy-ha.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ defaults
retries 3
option redispatch
maxconn 256000
contimeout 5000
clitimeout 50000
srvtimeout 50000
timeout connect 5s
timeout client 50s
timeout server 50s

listen artifactory_http 10.80.166.106:80
listen artifactory_http
bind :::80 v4v6
mode http
balance roundrobin
cookie SERVERID insert indirect nocache
Expand Down
24 changes: 10 additions & 14 deletions proxyexamples/haproxy/haproxy-ports.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -11,39 +11,35 @@ frontend normal
bind *:80
bind *:443 ssl crt /etc/haproxy/ssl
mode http
option forwardfor
reqadd X-Forwarded-Proto:\ https if { ssl_fc }
option forwardfor header X-Real-IP
reqirep ^([^\ :]*)\ /v2(.*$) \1\ /artifactory/api/docker/docker-virtual/v2\2
http-request add-header X-Forwarded-Proto https if { ssl_fc }
http-request replace-path /v2(.*$) /artifactory/api/docker/docker-virtual/v2\1
default_backend normal

frontend dockerhub
bind *:5001 ssl crt /etc/haproxy/ssl
mode http
option forwardfor
reqadd X-Forwarded-Proto:\ https if { ssl_fc }
option forwardfor header X-Real-IP
reqirep ^([^\ :]*)\ /v2(.*$) \1\ /artifactory/api/docker/docker-remote/v2\2
http-request add-header X-Forwarded-Proto https if { ssl_fc }
http-request replace-path /v2(.*$) /artifactory/api/docker/docker-remote/v2\1
default_backend normal

frontend dockerprod
bind *:5001 ssl crt /etc/haproxy/ssl
mode http
option forwardfor
reqadd X-Forwarded-Proto:\ https if { ssl_fc }
option forwardfor header X-Real-IP
reqirep ^([^\ :]*)\ /v1(.*$) \1\ /artifactory/api/docker/docker-prod-local/v1\2
reqirep ^([^\ :]*)\ /v2(.*$) \1\ /artifactory/api/docker/docker-prod-local2/v2\2
http-request add-header X-Forwarded-Proto https if { ssl_fc }
http-request replace-path /v1(.*$) /artifactory/api/docker/docker-prod-local/v1\1
http-request replace-path /v2(.*$) /artifactory/api/docker/docker-prod-local2/v2\1
default_backend normal

frontend dockerdev
bind *:5002 ssl crt /etc/haproxy/ssl
mode http
option forwardfor
reqadd X-Forwarded-Proto:\ https if { ssl_fc }
option forwardfor header X-Real-IP
reqirep ^([^\ :]*)\ /v1(.*$) \1\ /artifactory/api/docker/docker-dev-local/v1\2
reqirep ^([^\ :]*)\ /v2(.*$) \1\ /artifactory/api/docker/docker-dev-local2/v2\2
http-request add-header X-Forwarded-Proto https if { ssl_fc }
http-request replace-path /v1(.*$) /artifactory/api/docker/docker-dev-local/v1\1
http-request replace-path /v2(.*$) /artifactory/api/docker/docker-dev-local2/v2\1
default_backend normal

backend normal
Expand Down
5 changes: 3 additions & 2 deletions proxyexamples/haproxy/haproxy-subdomains-2.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ frontend normal
bind *:443 ssl crt /usr/local/etc/haproxy/ssl/my-cert.pem
mode http
option forwardfor
option forwardfor header X-Real-IP
acl is_docker_request path_beg -i /v2/

http-request set-var(req.subdomain) req.hdr(host),lower,regsub(\.artifactory\.test\.com$,) if { hdr_end(host) -i .artifactory.test.com }
http-request set-header X-Artifactory-Override-Base-Url https://%[hdr(host)]/artifactory
http-request set-path /artifactory/api/docker/%[var(req.subdomain)]%[path] if is_docker_request
reqadd X-Forwarded-Proto:\ https
option forwardfor header X-Real-IP
http-request add-header X-Forwarded-Proto https if { ssl_fc }
default_backend normal

backend normal
Expand Down
6 changes: 3 additions & 3 deletions proxyexamples/haproxy/haproxy-subdomains.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ frontend normal
bind *:80
bind *:443 ssl crt /etc/haproxy/ssl
mode http
option forwarder
reqadd X-Forwarded-Proto:\ https if { ssl_fc }
option forwardfor header X-Real-IP
http-request add-header X-Forwarded-Proto https if { ssl_fc }

acl n hdr_end(host) -i .dockertest.test
http-request set-var(sess.var) req.hdr(Host),field(1,"."),lower
http-request set-header X-Artifactory-Override-Base-Url https://%[hdr(host)]/artifactory
Expand All @@ -13,8 +13,8 @@ frontend normal

backend test
mode http
server localhost 127.0.0.1:8081
http-request set-path /artifactory/api/docker/%[var(sess.var)]%[path]
server localhost 127.0.0.1:8081

backend normal
mode http
Expand Down