How to send request to proxy pass url based on server name in nginx

Posted July 23, 2017 19.4k views

i configure ngnix proxy with ip and use it ip . its working perfect
but when i try to use in name server then its not working
after lot of searching i am finding something but same issue

Problem is i want to use like it     >>   ngnix proxy Ip     >>   ngin proxy ip

here is my configure which i use to set ip.. Please give me configure which i use and set name servers

## Basic reverse proxy server ##
## HTTP backend for ##
upstream httpweb  {
      server; # cPanel server

## Start ##
server {

    access_log  /var/log/nginx/log/www.example.access.log  main;
    error_log  /var/log/nginx/log/www.example.error.log;
    root   /usr/share/nginx/html;
    index  index.html index.htm;

    ## send request back to apache1 ##
    location / {
     proxy_pass  http://httpweb;
     proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
     proxy_redirect off;
     proxy_buffering 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;

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer


This makes no sense:     >>   ngnix proxy Ip     >>   ngin proxy ip

What are you trying to do? Please explain from start to end, without any configurations, just in words.