Apache 2.4 Reverse Proxy using HTTPd

Apache 2.4 Reverse Proxy using HTTPd

I created an AWS EC2 instance with a public IP, lets call it 100.0.0.0.

I added a rule for the security group to allow incoming HTTP traffic on port 80 for any IPv4.

I added to the config file in: /etc/httpd/conf/httpd.conf

<VirtualHost *:80>
    ProxyPreserveHost On
    ProxyPass /test/ http://www.example.com/
    ProxyPassReverse /test/ http://www.example.com/
</VirtualHost>

Which when I went to http://100.0.0.0/test/ , I got a 404 - Not Found displayed on my browser. Nothing in error_log.

I also tried this with a local host

<VirtualHost *:80>
    ProxyPreserveHost On
    ProxyPass /test/ http://localhost:8080/
    ProxyPassReverse /test/ http://localhost:8080/
</VirtualHost>

&

<VirtualHost *:80>
    ProxyPreserveHost On
    ProxyPass /test/ http://127.0.0.1:8080/
    ProxyPassReverse /test/ http://127.0.0.1:8080/
</VirtualHost>

Which gave me in the logs:

Connection refused: AH00957: http: attempt to connect to 127.0.0.1:8080 (127.0.0.1) failed

AH01114: HTTP: failed to make connection to backend: 127.0.0.1, referer: http://100.0.0.0/

Since this is created with AWS I also tried creating an outbound rule, where I allowed any for IPv4. Im not sure if I need to set any more rules in AWS, or if I missed a step configuring my proxy.

See doc I followed: https://linuxtechlab.com/apache-as-reverse-proxy-centos-rhel/

I also referenced: https://httpd.apache.org/docs/2.4/howto/reverse_proxy.html which lead me to the www.example.com example.

netstat -aon | grep 8080
TCP    0.0.0.0:8080           0.0.0.0:0              LISTENING       22304
TCP    [::]:8080              [::]:0                 LISTENING       22304
TCP    [::1]:8080             [::]:0                 LISTENING       25212

관련 정보