Nginx virtual host proxy_pass configuration

Written by Alex


We are going to do Nginx virtual host proxy pass configuration. In addition, we will clear topics that how we can proxied traffic from front-end URL to back end application.

We are using proxy pass solutions because our application running on the custom port which we don’t want to expos over the public that we configured domain on front and route traffic from domain name to application back end.

Nginx virtual host proxy_pass configuration

When NGINX proxies any request, it sends the request to the proxied server and fetches the response after that it sends it back to the clients. It is possible to proxy requests to an HTTP server or a non-HTTP server.

which can run an application stack with a specific framework for example like PHP or Python using a specific protocol. Support protocols include FastCGI, uwsgi, SCGI, and Memcached.

To pass a request to an HTTP proxied server, the proxy_pass directive is specified inside a configuration. For example:


location /some/path/ {

Nginx proxy_pass virtual host configuration

Below Steps for Nginx virtual host configuration

  1. Create file in /etc/nginx/conf.d/project-name.conf.
# vi /etc/nginx/conf.d/project-name.conf

Use the below configuration for Nginx proxy_pass configuration and change path as per your requirement.

server { 
listen 443;
 ssl on;
 server_tokens off;
 add_header Strict-Transport-Security "max-age=31536000;
 includeSubDomains" always;
 add_header Public-Key-Pins "pin-sha256=\"klO23nT2ehFDXCfx3eHTDRESMz3asj1muO+4aIdjiuY=\";
 add_header X-XSS-Protection "1; mode=block";
 add_header Referrer-Policy: origin-when-cross-origin;
 add_header Content-Security-Policy "img-src *";
 add_header X-Content-Type-Options nosniff;
 ssl_certificate /etc/pki/tls/certs/;
 ssl_certificate_key /etc/pki/tls/private/pulseapp.key;
	access_log /var/www/html/;
	error_log /var/www/html/;
 include /etc/nginx/default.d/*.conf;
 location /static/ { 
		root /var/www/html/;
 location /media/ { 
		root /var/www/html/;
 location / { 
	proxy_pass http://unix:/var/www/html/;
	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_set_header Host $host;

In the above configuration we have added domain name in server_name directive this is our front web URL where users will come and will do the activity and see their required content.

After that, the user will request to web URL and the web URL pass request to the application back-end.

In Conclusion

With the help of above all topics, you will be able to configure Nginx proxy_pass.

We hope you are like this article and this is useful for you. If you learn more about Linux, AWS Tips, and Tricks Please Bookmark this Website.

We are Daily Publish New Article in this Website WWW.BPMTECHGURU.IN and all post on this website is practically tested and 100% Work if you have any Problem Please Drop a Comment we are trying to resolve your problem.

About the author


Leave a Comment