Convert nginx configuration to haproxy


#1

Hi,

I am trying to convert my nginx configuraiton to haproxy:
nginx configuration:
location / {
proxy_pass http://[::1]:8088;
}

frontend fe_http
mode http
bind *:80
option forwardfor

Redirect to https

redirect scheme https code 301 if ! { ssl_fc }

default_backend nodes-http-80

backend nodes-http-80
mode http
server default [::1]:8088

8088 is what webserver listneing to.
I am getting like error as below:
00000000:fe_http.accept(0006)=0007 from [:20842]
00000000:fe_http.clireq[0007:ffffffff]: GET / HTTP/1.1
00000000:fe_http.clihdr[0007:ffffffff]: Host:
00000000:fe_http.clihdr[0007:ffffffff]: User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:57.0) Gecko/20100101 Firefox/57.0
00000000:fe_http.clihdr[0007:ffffffff]: Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
00000000:fe_http.clihdr[0007:ffffffff]: Accept-Language: en-US,en;q=0.5
00000000:fe_http.clihdr[0007:ffffffff]: Accept-Encoding: gzip, deflate
00000000:fe_http.clihdr[0007:ffffffff]: Connection: keep-alive
00000000:fe_http.clihdr[0007:ffffffff]: Upgrade-Insecure-Requests: 1
00000000:nodes-http-80.srvrep[0007:0008]: HTTP/1.1 404 Not Found
00000000:nodes-http-80.srvhdr[0007:0008]: Connection: close
00000000:nodes-http-80.srvhdr[0007:0008]: Server:
00000000:nodes-http-80.srvhdr[0007:0008]: Date: Mon, 12 Feb 2018 14:05:17 GMT
00000000:nodes-http-80.srvhdr[0007:0008]: Content-Length: 169
00000000:nodes-http-80.srvhdr[0007:0008]: Content-Type: text/html
00000000:nodes-http-80.srvhdr[0007:0008]: Content-Encoding: gzip
00000000:nodes-http-80.srvhdr[0007:0008]: Vary: Accept-Encoding
00000000:nodes-http-80.srvcls[0007:0008]
00000001:fe_http.clireq[0007:ffffffff]: GET /favicon.ico HTTP/1.1
00000001:fe_http.clihdr[0007:ffffffff]: Host: 172.18.138.3
00000001:fe_http.clihdr[0007:ffffffff]: User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:57.0) Gecko/20100101 Firefox/57.0
00000001:fe_http.clihdr[0007:ffffffff]: Accept: /
00000001:fe_http.clihdr[0007:ffffffff]: Accept-Language: en-US,en;q=0.5
00000001:fe_http.clihdr[0007:ffffffff]: Accept-Encoding: gzip, deflate
00000001:fe_http.clihdr[0007:ffffffff]: Connection: keep-alive
00000001:nodes-http-80.srvcls[0007:0008]
00000001:nodes-http-80.clicls[0007:0008]
00000001:nodes-http-80.closed[0007:0008]
00000002:fe_http.accept(0006)=0007 from [10.220.22.107:20844]
00000002:fe_http.clireq[0007:ffffffff]: GET /favicon.ico HTTP/1.1
00000002:fe_http.clihdr[0007:ffffffff]: Host:
00000002:fe_http.clihdr[0007:ffffffff]: User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:57.0) Gecko/20100101 Firefox/57.0
00000002:fe_http.clihdr[0007:ffffffff]: Accept: /
00000002:fe_http.clihdr[0007:ffffffff]: Accept-Language: en-US,en;q=0.5
00000002:fe_http.clihdr[0007:ffffffff]: Accept-Encoding: gzip, deflate
00000002:fe_http.clihdr[0007:ffffffff]: Connection: keep-alive
00000002:nodes-http-80.srvrep[0007:0008]: HTTP/1.1 404 Site or Page Not Found
00000002:nodes-http-80.srvhdr[0007:0008]: Server: GoAhead-Webs
00000002:nodes-http-80.srvhdr[0007:0008]: Date: Mon Feb 12 14:05:17 2018
00000002:nodes-http-80.srvhdr[0007:0008]: Pragma: no-cache
00000002:nodes-http-80.srvhdr[0007:0008]: Cache-Control: no-cache
00000002:nodes-http-80.srvhdr[0007:0008]: Content-Type: text/html

Thanks


#2

Clearly your backend doesn’t know what do to with this requests, responding with “404 Not Found” or “404 Site or Page Not Found”.

You have to figure out what your backend expects to find the site, haproxy just forwards the request to port 8088.

Did you check if specific Host headers are required and whether you set them in nginx?