I have server1 with public IP and server2 with local IP, I want to access my app hosted by apache on the server2 from server1 public IP using nginx reverse proxy. Here's my config.
Apache2 config
<VirtualHost *:80>
ServerName ci_app.local
DocumentRoot /var/www/ci_app/public
<Directory /var/www/ci_app/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/apache2/ACD_error.log
CustomLog /var/log/apache2/ACD_requests.log combined
</VirtualHost>
Nginx config
server {
listen 8000;
server_name ci_app.local;
port_in_redirect on;
location / {
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://<server2_local_ip>:80/;
}
}
Using that configuration I only get the default Apache virtualhost when accessing the http://<server1_public_ip>:8000.
I've tried changing the Nginx header config to
proxy_set_header Host ci_app.local
Which allow me to access the app but rather than server1 public IP the ajax sent the request to ci_app.local which unaccessible from outside the local network.
So, how to correctly reverse proxy my app?