Httpd – Cannot get HTTPD 2.4 to start when using the Require IP command for access control

apache-2.4cidrhttpd

This was intended to be a comment on a similar question but since Stack is so restrictive about comments I'm reposting it as they want it:

: Here's the documentation: http://httpd.apache.org/docs/2.4/en/mod/mod_authz_core.html#require)

Here's the config file:
Options Indexes FollowSymLinks AllowOverride None Require ip $CIDR ~

The error still is: May 24 20:54:54 ip-172-16-5-34.us-west-1.compute.internal httpd[23044]: AH00526: Syntax error on line 3 of /etc/httpd/conf.d/httpd.conf: May 24 20:54:54 ip-172-16-5-34.us-west-1.compute.internal httpd[23044]: Invalid command 'Require', perhaps misspelled or defined by a module not included in the server configuration

What am I missing?

It looks like the RequireAny or RequireAll commands may help but they don't.

For your reference the information provided here did not suffice:
How do I require an IP range instead of 1 IP?

Best Answer

Require ip $CIDR ~ is not proper in the Options directive. The documentation is very clear about what may be in an Options directive.

Require is its own directive, which can be in a Container, but certainly not within an Options directive.

When you get past that, your next problem will probably be the Require ip $CIDR ~. Where are you getting this $CIDR ~ bit? You need to follow proper specification for access control by host and specification of Require ip directives.

If in fact, you actually have Require ip $CIDR ~ on its own config line, as opposed to what you put in the question, then refer to the last part of this answer now (i.e. use proper host/ip specification with the Require ip) and also see the following notes.

NOTE: You must have mod_authz_core loaded to use the Require (and related) directives.

NOTE ALSO: You should be running apachectl -t to check config changes BEFORE trying to restart Apache, rather than finding these problems by crashing Apache.

Related Topic