You are looking at the documentation of a prior release. To read the documentation of the latest release, please
visit here.
New to Voyager? Please start here.
Rewrite Target
In some scenarios the exposed URL in the backend service differs from the specified path in the Ingress rule. This will cause any request to return 404. In such scenarios you can set the path expected by the service using ingress.appscode.com/rewrite-target
annotation. This will be applied globally for all paths.
Ingress Example
apiVersion: voyager.appscode.com/v1beta1
kind: Ingress
metadata:
name: test-ingress
namespace: default
annotations:
ingress.appscode.com/rewrite-target: "/bar"
spec:
rules:
- host: voyager.appscode.test
http:
paths:
- path: /foo
backend:
serviceName: test-server
servicePort: 80
It will add following rule to replace request path in generated haproxy.cfg:
reqrep ^([^\ :]*)\ /foo(.*$) \1\ /bar\2
Generated haproxy.cfg:
# HAProxy configuration generated by https://github.com/appscode/voyager
# DO NOT EDIT!
global
daemon
stats socket /tmp/haproxy
server-state-file global
server-state-base /var/state/haproxy/
# log using a syslog socket
log /dev/log local0 info
log /dev/log local0 notice
tune.ssl.default-dh-param 2048
ssl-default-bind-ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!3DES:!MD5:!PSK
hard-stop-after 30s
defaults
log global
# https://cbonte.github.io/haproxy-dconv/1.7/configuration.html#4.2-option%20abortonclose
# https://github.com/voyagermesh/voyager/pull/403
option dontlognull
option http-server-close
# Timeout values
timeout client 50s
timeout client-fin 50s
timeout connect 5s
timeout server 50s
timeout tunnel 50s
# Configure error files
# default traffic mode is http
# mode is overwritten in case of tcp services
mode http
frontend http-0_0_0_0-80
bind *:80
mode http
option httplog
option forwardfor
acl is_proxy_https hdr(X-Forwarded-Proto) https
acl acl_voyager.appscode.test hdr(host) -i voyager.appscode.test
acl acl_voyager.appscode.test hdr(host) -i voyager.appscode.test:80
acl acl_voyager.appscode.test:foo path_beg /foo
use_backend test-server.default:80 if acl_voyager.appscode.test acl_voyager.appscode.test:foo
backend test-server.default:80
reqrep ^([^\ :]*)\ /foo(.*$) \1\ /bar\2
server pod-test-server-68ddc845cd-x5c78 172.17.0.2:8080
Get url for ingress service:
$ minikube service --url voyager-test-ingress
http://192.168.99.100:31228
Send request with path /foo
:
$ curl -v -H 'Host: voyager.appscode.test' 192.168.99.100:31228/foo
* Trying 192.168.99.100...
* Connected to 192.168.99.100 (192.168.99.100) port 31228 (#0)
> GET /foo HTTP/1.1
> Host: voyager.appscode.test
> User-Agent: curl/7.47.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Mon, 19 Feb 2018 05:53:14 GMT
< Content-Type: text/plain
< Transfer-Encoding: chunked
< Server: echoserver
<
Hostname: test-server-68ddc845cd-x5c78
Pod Information:
-no pod information available-
Server values:
server_version=nginx: 1.13.3 - lua: 10008
Request Information:
client_address=172.17.0.5
method=GET
real path=/bar
query=
request_version=1.1
request_uri=http://voyager.appscode.test:8080/bar
Request Headers:
accept=*/*
connection=close
host=voyager.appscode.test
user-agent=curl/7.47.0
x-forwarded-for=172.17.0.1
Request Body:
-no body in request-
* Connection #0 to host 192.168.99.100 left intact
Here although original request is sent to path /foo
, it is redirected to path /bar
.