I have an Apache 2.4 VirtualHost on an AWS EC2 instance with the following config:
<Directory /srv/www/example.org>
Require ip [REDACTED] # Office IP
Require local
</Directory>
When I make a request from the redacted external office IP address it works fine, but when I make a request from the EC2 instance I get a 401 Unauthorized error. I tried replacing Require local
with Require ip 127.0.0.1
to no avail.
The only way I am able to make requests from the local machine is to add its external IP address e.g Require ip 123.45.67.89
.
I had a look at the access log and all requests made from the local machine are logged as having come from the external IP address rather than 127.0.0.1.
The /etc/resolv.conf
file looks like this:
options timeout:2 attempts:5
; generated by /usr/sbin/dhclient-script
search eu-west-2.compute.internal
nameserver 172.31.0.2
Could this be happening because the IP/hostname is being resolved externally by another AWS service?
Can I change any server config so that Apache sees requests from the EC2 instance as being local, so I can use the Require local
directive?