I run a web game embedded in Wordpress/Jetty behind HAProxy 1.5 on CentOS 7 Linux.
The website can be accessed both as http
and https
.
I have modified Wordpress to display player profile pages at the URLs like:
https://slova.de/player-12345
where 12345
is a numeric player id in my web game.
This works well, but I would like to simplify the above URLs to
https://slova.de/12345
and then use HAProxy to prepend the "player-" part to numeric-only paths.
So I have added to /etc/haproxy/haproxy.cfg
file the line:
http-request redirect code 301 prefix /player- if { path_end /5 }
This results however in the broken URL for some reason:
Below is my complete haproxy.cfg
file to provide more context:
global
log 127.0.0.1 local2
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 4000
user haproxy
group haproxy
daemon
stats socket /var/lib/haproxy/stats
tune.ssl.default-dh-param 2048
defaults
mode http
log global
option httplog
option dontlognull
option http-server-close
option forwardfor except 127.0.0.0/8
option redispatch
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 1m
timeout server 1m
timeout http-keep-alive 10s
timeout check 10s
maxconn 3000
# for WebSocket connections
timeout tunnel 1h
timeout client-fin 1m
frontend public
bind 144.76.184.151:80
bind 144.76.184.151:443 ssl crt /etc/pki/tls/certs/slova.de.pem no-sslv3
http-request deny if { path_beg /xmlrpc.php }
http-request redirect code 301 prefix /player- if { path_end /5 }
default_backend jetty
backend jetty
server domain 127.0.0.1:8080 send-proxy