HAProxy community

Need Help with Nginx Conversion to HaProxy Backend

#1

Hi, i need help in Converting an nginx Config to an HaProxy Backend.
I dont have the neccessary knowledge to do this but this is our Only Configuration in HaProxy that i didnt get to work.

We have HaProxy 1.7 in Place and get this Nginx Config.

server {
listen :80;
server_name merkur-stylo.vrsmedia.de;
access_log /var/log/nginx/stylotest.log;
location / {
proxy_pass http:// http://10.32.2.228:8080/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}

My HaProxy Backend shows the following Code but It`s not working.

backend merkur_stylo
balance source
mode http
option forwardfor header X-Real-IP
http-request set-header Host 10.32.2.228
http-request set-header X-Forwarded-Host 10.32.2.228
http-request set-header X-Forwarded-Proto http
server merkur-stylo 10.32.2.228:8080 check inter 5000

The URL can be tested with merkur-stylo.vrsmedia.de/stylo
But the Editor cant found the neccessary Pictures but its available.

The Stylo is bound via vpn Gateway and is in original only available due to the internal Network from our Publisher.

Can anybody help me to Convert this to an working HaProxy Backend ?

Thank you.

0 Likes

#2

Why are you setting Host header in the backend? If the end server is running multiple applications with dedicated VHOSTs, it won’t work.

0 Likes

#3

Hi, didn`t know the backgrounds really. The Publisher holds this answer in secrects. I got only this NGinX Snippet with the Answer that this Setup should work. So i have to transform this to HaProxy 1.7.

I didn`t really know much about HaProxy. Its the first time that i have it set up.

0 Likes

#4

I believe this is the minimum config that should work in your case:

frontend merkur_stylo_server
bind 0.0.0.0:80
use_backend merkur_stylo_back if { hdr(Host) -i merkur-stylo.vrsmedia.de }
mode http
option httplog
default_backend merkur_stylo_back

backend merkur_stylo_back
mode http
balance roundrobin
option forwardfor
server SERVER1 10.32.2.228:8080 check

Make sure the HAProxy server is able to connect to 10.32.2.228 on port 8080

0 Likes

#5

Thank you, but didn`t work for me. You can Check by this URL
http://merkur-stylo.vrsmedia.de:8080/stylo/

The Editor loads up, But the Images are not shown. The Images are in an separate WebDAV Folder on wich we have access with an separate URL behind the VPN Connection.

Error Message:
LoadImage error: http://merkur-stylo.vrsmedia.de:8080/stylo/ProxyServlet?url=http%3A%2F%2Fmerkur-stylo.vrsmedia.de%3A8080%2Fstylo%2Fimages%2Fostern%2Flogo12.png&preview

I Think I have tor work with Proxy Pass or something like That.

0 Likes