Linux Nginx As Reverse Proxy Task

Hi Antony

/etc/nginx/nginx.conf
user nginx; => user apache; make Nginx work under this user

server {
listen 8095 default;
server_name 172.16.238.16;
}

location / {
root /var/www/html; => Move the root line to location section

}

Thank you @devops503 , will try your changes

Hi @devops503 , are these changes to be done all in the /etc/nginx/nginx.conf file ?

Yes,

The changes on nginx.conf

/etc/nginx/nginx.conf

user nginx; => user apache; make Nginx work under this user

server {
listen 8095 default;
server_name 172.16.238.16;
}

location / {
root /var/www/html; => Move the root line to location section
proxy_pass http://127.0.0.1:6000/;
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr
}

All necessary settings for proxing
/etc/nginx/conf.d/proxy.conf
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 10 m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;

1 Like

Thank you @devops503 , that worked !!

kindly help i am not able to install nginx.
and please provide me further steps to complete the task.
Thanks


@antonysavio1111 @devops5032 @sanyamc230493 @kiran

Hi , you need to install epel-release before you can install nginx ,ie,
yum install epel-release -y
yum install nginx -y

For the main setup , follow the steps mentioned in the topic

Thank you @antonysavio1111 Completed the Task Successfully.

@devops503…For this task I installed apache first and the did changes in conf file and changed the port as mentioned in the problem statement…and the installed nginx and followed the steps you mentioned…but after starting nginx …getting the error…Also , in nginx status i checked… something is wrong with the conf file…plz advice what i am doing wrong/…

Can anyone plz suggest …what did i do wrong in configuration file…

nginx -t with the help of this command you can config error in nginx config file

Edit the file and change below parameters according to your question.
listen 8096;
listen [::]:8096;
server_name 172.16.238.16;
Under location tab, add below line
proxy_pass http://172.16.238.16:8082

Is it 5000 proxy_pass http://127.0.0.1:5000/; your Apache port ??

After running
systemctl start nginx
Run
journalctl -xe | grep emerg
To get exactly what the problem is

I am having the same issues, any input here guys ??

any luck with this ?

@Ayman, @kodekloud-support3 Same my task is failed, but as per result I done correctly everything.

As per my understanding of the question, reverse proxy is configured successfully and both nginx and apache servers are running.

Hello Devops503/Everyone,

Can you please help me in resloving nginx reverse proxy task.Please correct me where am doing wrong my nginx config file,proxy file and the error

Thanks
Sree

@sreedhar I see there is a syntax error with the setting “client_max_body_size”. The value is “10 m” instead “10m”. Try removing the space and see.

Thanks Salim.Unfortunately task expired ,will try again when i get assigned

Step By Step Solution for Beginners: Linux Nginx as Reverse Proxy KodeKloud

Hi @devops503,

Thanks for the answer. Just wondering, since nginx has been pointing all port 8095 request to 6000, do we still need to specify the root location for httpd? Is it default setting once httpd is installed?

Thanks,
Chance