nginxconfig.io icon indicating copy to clipboard operation
nginxconfig.io copied to clipboard

nginx test fails when nginxconfig.io url exceeds length limit

Open ProphetLamb opened this issue 3 years ago • 1 comments

Steps to reproduce

  • Create a configuration whose digitalocean.com/community/tools/nginx URL is over 5000 characters in length.
  • Import the configuration into /etc/nginx
  • Run nginx -t

Error occurs

nginx: [emerg] too long parameter "# https://..."
nginx: configuration file /etc/nginx/nginx.conf test failed        

Workaround

Yank & delete the comment and put into /etc/nginx/nginxconfig.io.url. Run nginx -t again, the check is successful, and the service starts correctly.

Suggested solution

Store the URL in a separate file, similar to the workaround, instead of writing to nginx.conf. https://github.com/digitalocean/nginxconfig.io/blob/2eac584166e8c5ba095322386533ddd9a0272b8b/src/nginxconfig/generators/conf/nginx.conf.js#L37

ProphetLamb avatar Jun 01 '22 11:06 ProphetLamb

Storing the URL in a separate file has a number of other benefits, when deploying a configuration:

  1. Cleaning up nginx.conf, so that the user doesnt have to scroll 10 wrapped lines of URL before reading the actual configuration.
  2. Can easily copy the URL, with only cat available.
  3. Solving the bug I am reporting

ProphetLamb avatar Jun 01 '22 11:06 ProphetLamb

Maybe I can make a PR about this, let me check some things:

Instead of:

# Generated by nginxconfig.io
# https://www.digitalocean.com/community/tools/nginx?global.security.limitReq=true

You recommend:

# Generated by nginxconfig.io
# See URL.md to get the configuration shared link

And in URL.md

Configuration shared link of nginxconfig.io:
https://www.digitalocean.com/community/tools/nginx?global.security.limitReq=true

That's correct? @ProphetLamb Opinitions? @MattIPv4

MrJmpl3 avatar Oct 03 '22 23:10 MrJmpl3

I would suggest writing the URL to a dedicated nginxconfig.txt file, and just the URL (not an MD file with additional text)

MattIPv4 avatar Oct 03 '22 23:10 MattIPv4

nginxconfig.txt

https://www.digitalocean.com/community/tools/nginx?global.security.limitReq=true

Is correct?

MrJmpl3 avatar Oct 03 '22 23:10 MrJmpl3