Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mistakes in Unit configuration #412

Closed
TheAndrey opened this issue Aug 12, 2024 · 4 comments
Closed

Mistakes in Unit configuration #412

TheAndrey opened this issue Aug 12, 2024 · 4 comments
Assignees
Labels
🧐 Bug: Needs Confirmation Something isn't working, but needs to be confirmed by a team member.

Comments

@TheAndrey
Copy link

TheAndrey commented Aug 12, 2024

Steps To Reproduce

Hi,
I decided to build my application image based on Nginx Unit. I am having difficulty applying the custom server configuration due to errors found in the scripts.

Outcome

  1. Disabling logging of healthcheck does not work. Although there is a rule in the configuration, it is always overwritten by the script. Custom additional configs cannot affect this. You should delete the specified line in the initialization script.

  2. Private IP address ranges are missing in the reverse proxy configuration, although they are specified in Nginx. I want to use Unit as an application server located behind the upstream Nginx on the host.

  3. The current configuration is very crude. I had to completely rewrite the config. In this case, it only works index.php at the same time, all other php scripts are downloaded as regular files. index.php you can also download it if you specify its name in the URL.

I got something like this configuration with my fixes.

{

  "listeners": {
    "*:8080": {
      "pass": "routes",
      "forwarded": {
        "client_ip": "X-Forwarded-For",
        "protocol": "X-Forwarded-Proto",
        "recursive": false,
        "source": [
          "172.16.0.0/12"
        ]
      }
    }
  },

  "routes": [
    {
      "match": {
        "uri": "/healthcheck"
      },
      "action": {
        "return": 200
      }
    },
    {
      "match": {
        "uri": [
          "/",
          "*.php",
          "*.php/*"
        ]
      },
      "action": {
        "pass": "applications/php/direct"
      }
    },
    {
      "action": {
        "share": "/var/www/html/public$uri",
        "fallback": {
          "pass": "applications/php/index"
        }
      }
    }
  ],

  "applications": {
    "php": {
      "type": "php",
      "processes": {
        "max": 5,
        "spare": 1,
        "idle_timeout": 30
      },
      "targets": {
        "index": {
          "root": "/var/www/html/public/",
          "script": "index.php"
        },
        "direct": {
          "root": "/var/www/html/public/",
          "index": "index.php"
        }
      }
    }
  }

}

It is imperfect. index.php it does not start when going to the directory, unless you explicitly specify the URI in the config.

Affected Docker Images

  • serversideup/php:7.4-unit

Anything else?

No response

@TheAndrey TheAndrey added the 🧐 Bug: Needs Confirmation Something isn't working, but needs to be confirmed by a team member. label Aug 12, 2024
@jaydrogers
Copy link
Member

Thanks for opening this up! Yes, this was the first Unit configuration that I wrote and I am still learning.

I'd be glad to take on a PR if you have more experience. I'd like it to replicate the features of the fpm-nginx as much as possible.

@TheAndrey
Copy link
Author

TheAndrey commented Aug 13, 2024

I'm also getting to know Unit for now. I solved problems by studying the documentation. I'm still working on the config. On your part, you need to finalize the configuration scripts.

Next problem. Any scripts located in /etc/unit/config.d completely overwrite the Unit configuration. To avoid this, we need to be able to specify the URI where the configuration file will be uploaded, as described in the documentation.

I still don't understand why SSL support and Cloudflare IP processing are needed, if this should be handled by a upstream server. This only complicates the configuration. The task of the application server is only route processing.

@jaydrogers
Copy link
Member

I still don't understand why SSL support and Cloudflare IP processing are needed, if this should be handled by a upstream server.

We can't always assume this, so that's why we have this included.

Keep me posted on what you learn and I'd love to review any suggestions for improvement.

@jaydrogers
Copy link
Member

Thanks again for your report @TheAndrey!

I am working on v3.4 and I am breaking your suggestions into different tasks. Here is where everything at:

I will update each issue individually and close this one. I appreciate your feedback!

@jaydrogers jaydrogers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 2, 2024
@github-project-automation github-project-automation bot moved this from In progress to Done in serversideup/php v3.4 Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧐 Bug: Needs Confirmation Something isn't working, but needs to be confirmed by a team member.
Projects
Status: Done
Development

No branches or pull requests

2 participants