Git Product home page Git Product logo

Comments (6)

pursultani avatar pursultani commented on June 3, 2024 1

@guimouraumbler @danielvieiravega looking at the log output my first suspicion is the API changes in newer versions of HAProxy.

from haproxy-error-page.

guimouraumbler avatar guimouraumbler commented on June 3, 2024

The error also happens following the steps for the docker test.

from haproxy-error-page.

guimouraumbler avatar guimouraumbler commented on June 3, 2024

I've found an "error". The script "works" on haproxy version 1.6. We use here versions 1.8, 1.9 (because we need to use http v2 and this is only available on these versions).

In version 1.6, I still have some trouble, when I access the page, sometimes come to an error and on logs appears:

runtime error: /etc/haproxy-persistent/error-page.lua:103: 'close' needs 1 arguments.

What can I do about this? And is there any possibility to use this script on version 1.9?

OBS: The error I commented that occurs in docker, occurs because the image downloads the latest version of haproxy (haproxy: alphine)

Thanks.

from haproxy-error-page.

danielvieiravega avatar danielvieiravega commented on June 3, 2024

Hi!
I'm having a similar issue.
I'm using the labs.play-with-docker.com to test your script.
I start the environment using docker-compose up, then I run the curl -v localhost:8080 and it works properly returning a 200 status code.
BUT when a I run curl -v localhost:8080/blabla it returns the expected 404 status code, but the following error is displayed on the screen:

$ curl -v localhost:8080/dfa
proxy_1 | [debug] 017/160329 (10) : lua.error-page: rewrite error page: 404
proxy_1 | [ALERT] 017/160329 (10) : Lua function 'error-page': runtime error: 0 from [C] method 'set', /usr/local/etc/haproxy/scripts/error-page.lua:101 C function line 96.

image

Can you help to solve this problem?

Thanks.

from haproxy-error-page.

marceldegraaf avatar marceldegraaf commented on June 3, 2024

It took me a good part of today to figure this out, but I've found out why this breaks in HAProxy 1.9+. Hidden in the HAProxy changelog I found this line:

MAJOR: lua: Forbid calls to Channel functions for LUA scripts in HTTP proxies

This is the commit that change relates to. The smoking gun is in the commit message:

Functions from then (sic) Channel class are now forbidden for LUA scripts called from HTTP proxies [...] following functions are concerned: Channel.get, Channel.dup, Channel.getline, Channel.set, Channel.append, Channel.send, Channel.forward

This means that for frontends using mode http the Lua script will never be able to call the res.set and res.send functions.

@pursultani do you know if there is a way to make this script work on HAProxy 1.9+ in mode tcp?

from haproxy-error-page.

pursultani avatar pursultani commented on June 3, 2024

Nice catch @marceldegraaf! It seems to me that unfortunately there's no way around it. mode tcp won't work since it requires not only the status operator for the ACL but also the HTTP status from TXN fetch class to lookup the right error page.

One disgraceful way to do it in to pass every response through the script (in TCP mode) parse it, and act accordingly. But since it's defeats the purpose of being HA it seems to be pointless.

from haproxy-error-page.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.