Last active
August 24, 2020 04:07
-
-
Save kirilkirkov/7cbb98565fbc67058c9b to your computer and use it in GitHub Desktop.
How To Configure Nginx as a Reverse Proxy for Apache (Linux)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I will consider that you have three servers. First one with apache, second one with nginx server and third with bind. | |
1: Go to bind server (/etc/bind/zones/) and setup new A records to site that we will run. | |
- nginx5 IN A 192.168.0.1 | |
- apache5 IN A 192.168.0.2 | |
2: Set vhost with new site for port 8080 (/etc/apache2/sites-available/) | |
<VirtualHost *:8080> | |
ServerName apache5.mysite.com | |
ServerAdmin webmaster@localhost | |
DocumentRoot /var/www/apache5 | |
<Directory /var/www/apache5> | |
Options Indexes ExecCGI FollowSymLinks | |
</Directory> | |
ErrorLog ${APACHE_LOG_DIR}/error.log | |
CustomLog ${APACHE_LOG_DIR}/access.log combined | |
</VirtualHost> | |
And upload some jpg file example. | |
3: Go to nginx server and configure vhost for new site (nginx5.mysite.com) (/etc/nginx/sites-available/) | |
server { | |
listen 80; | |
server_name nginx5.mysite.com; | |
access_log off; | |
error_log /var/log/apache2/yourdomain.com-error_log crit; | |
location / { | |
client_max_body_size 10m; | |
client_body_buffer_size 128k; | |
proxy_send_timeout 90; | |
proxy_read_timeout 90; | |
proxy_buffer_size 128k; | |
proxy_buffers 4 256k; | |
proxy_busy_buffers_size 256k; | |
proxy_temp_file_write_size 256k; | |
proxy_connect_timeout 30s; | |
proxy_pass http://192.168.0.1:8080; //IP OF APACHE SERVER ON PORT 8080 | |
proxy_set_header Host $host; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
} | |
} | |
4: Open http://nginx5.mysite.com and must see information about apache directory. | |
WHAT IS REVERSE PROXY: https://en.wikipedia.org/wiki/Reverse_proxy | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment