puppetlabs-apache icon indicating copy to clipboard operation
puppetlabs-apache copied to clipboard

Display of RewriteRule in vhost config files

Open teluq-pbrideau opened this issue 8 months ago • 1 comments

Use Case

When I define multiple RewriteRule, they are not very well displayed in the config file, there is too much space between them and there is no sense they are related to each other…

  apache::vhost { 'example.com':
    rewrites => [
      {
        comment => 'Example rules 1',
        rewrite_rule => [
          '"\/(foo\/)" - [F]',
          '"\/(bar\/)" - [F]',
          '"\/(baz\/)" - [F]',
          '"\/(qux\/)" - [F]',
          '"\/(quux\/)" - [F]',
        ],
      },
      {
        comment => 'Example rules 2',
        rewrite_rule => [
          '"\/(another_foo\/)" - [F]',
          '"\/(another_bar\/)" - [F]',
          '"\/(another_baz\/)" - [F]',
          '"\/(another_qux\/)" - [F]',
          '"\/(another_quux\/)" - [F]',
        ],
      },
    ],
  }
[...]
  # Example rules 1
  RewriteRule "(\/foo\/)" - [F]

  RewriteRule "(\/bar\/)" - [F]

  RewriteRule "(\/baz\/)" - [F]

  RewriteRule "(\/qux\/)" - [F]

  RewriteRule "(\/quux\/)" - [F]

  # Example rules 2
  RewriteRule "(\/another_foo\/)" - [F]

  RewriteRule "(\/another_bar\/)" - [F]

  RewriteRule "(\/another_baz\/)" - [F]

  RewriteRule "(\/another_qux\/)" - [F]

  RewriteRule "(\/another_quux\/)" - [F]

Describe the Solution You Would Like

I feel these RewriteRule should not be this much spaced. I think this would be much more readable:

  # Example rules 1
  RewriteRule "(\/foo\/)" - [F]
  RewriteRule "(\/bar\/)" - [F]
  RewriteRule "(\/baz\/)" - [F]
  RewriteRule "(\/qux\/)" - [F]
  RewriteRule "(\/quux\/)" - [F]

  # Example rules 2
  RewriteRule "(\/another_foo\/)" - [F]
  RewriteRule "(\/another_bar\/)" - [F]
  RewriteRule "(\/another_baz\/)" - [F]
  RewriteRule "(\/another_qux\/)" - [F]
  RewriteRule "(\/another_quux\/)" - [F]

Describe Alternatives You've Considered

Not caring about how the config file looks!

Additional Context

Other related config seems grouped together, for example when there is TLS config:

  ## SSL directives
  SSLEngine on
  SSLCertificateFile      "/etc/pki/tls/certs/example.com.crt"
  SSLCertificateKeyFile   "/etc/pki/tls/private/example.com.key"
  SSLCACertificateFile    "/etc/pki/tls/certs/ca-bundle.crt"

teluq-pbrideau avatar Feb 25 '25 19:02 teluq-pbrideau