Welcome! Log In Create A New Profile

Advanced

Re: Proxy Pass

Sathish Kumar
May 23, 2019 09:26PM
Hi All,

I have now tried to use FQDN but still same issue.

server 1
server_name abc.com;
access_log /var/log/nginx/abc.access.log;
error_log /var/log/nginx/abc.error.log warn;
location /abc {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_pass_header X_CUSTOM_HEADER;
proxy_pass https://def.com/abc;
}

Backend Server

server_name def.com;
access_log /var/log/nginx/def.access.log;
error_log /var/log/nginx/def.error.log warn;
location /abc {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://localhost:1111;

}

server_name ghi.co.com;
access_log /var/log/nginx/ghi.access.log;
error_log /var/log/nginx/ghi.error.log warn;
location /xyz {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://localhost:2222;

}

Still the /var/log/nginx/ghi.access.log loaded with the requests which
comes to def.com. Can you help me fix this issue.

Thanks & Regards
Sathish Kumar.V


On Fri, May 24, 2019 at 8:07 AM Sathish Kumar <satcse88@gmail.com> wrote:

> Hi Team,
>
> Please ignore my previous email. Kindly check the below config and suggest
> me a solution.
>
> server 1
> server_name abc.com;
> access_log /var/log/nginx/abc.access.log;
> error_log /var/log/nginx/abc.error.log warn;
> location /abc {
> proxy_set_header X-Real-IP $remote_addr;
> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
> proxy_set_header Host $http_host;
> proxy_pass_header X_CUSTOM_HEADER;
> proxy_pass https://1.1.1.1/abc;
>
> }
>
> Backend Server
>
> server_name def.com;
> access_log /var/log/nginx/def.access.log;
> error_log /var/log/nginx/def.error.log warn;
> location /abc {
> proxy_set_header X-Real-IP $remote_addr;
> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
> proxy_set_header Host $host;
> proxy_pass http://localhost:1111;
>
> }
>
> server_name ghi.co.com;
> access_log /var/log/nginx/ghi.access.log;
> error_log /var/log/nginx/ghi.error.log warn;
> location /xyz {
> proxy_set_header X-Real-IP $remote_addr;
> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
> proxy_set_header Host $host;
> proxy_pass http://localhost:2222;
>
> }
>
>
> If I enable this Nginx Config, the virtual hosts on the Backend server
> like ghi.co.com are logging with the requests coming to def.com
>
> Can you let me know,what I am missing and why I am facing incorrect
> logging requests to the file /var/log/nginx/ghi.access.log.
>
> Thanks & Regards
> Sathish Kumar.V
>
>
> On Fri, May 24, 2019 at 8:04 AM Sathish Kumar <satcse88@gmail.com> wrote:
>
>> Hi Team,
>>
>> I am already setting below headers.
>> server 1
>> server_name abc.com;
>> access_log /var/log/nginx/abc.access.log;
>> error_log /var/log/nginx/abc.error.log warn;
>> location /abc {
>> proxy_set_header X-Real-IP $remote_addr;
>> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
>> proxy_set_header Host $http_host;
>> proxy_pass_header X_CUSTOM_HEADER;
>> proxy_pass https://1.1.1.1/abc;
>>
>> }
>>
>> Backend Server
>>
>> server_name def.com;
>> access_log /var/log/nginx/def.access.log;
>> error_log /var/log/nginx/def.error.log warn;
>> location /abc {
>> proxy_set_header X-Real-IP $remote_addr;
>> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
>> proxy_set_header Host $host;
>> proxy_pass http://1.1.1.1/abc;
>>
>> }
>>
>> server_name ghi.co.com;
>> access_log /var/log/nginx/ghi.access.log;
>> error_log /var/log/nginx/ghi.error.log warn;
>> location /xyz {
>> proxy_set_header X-Real-IP $remote_addr;
>> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
>> proxy_set_header Host $host;
>> proxy_pass http://1.1.1.1/xyz;
>>
>> }
>>
>>
>> If I enable this Nginx Config, the virtual hosts on the Backend server
>> like ghi.co.com are logging with the requests coming to def.com
>>
>> Can you let me know,what I am missing and why I am facing incorrect
>> logging requests to the file /var/log/nginx/ghi.access.log.
>>
>> Thanks & Regards
>> Sathish Kumar.V
>>
>>
>> On Fri, May 24, 2019 at 7:35 AM Sathish Kumar <satcse88@gmail.com> wrote:
>>
>>> Hi Rozitis,
>>>
>>> Thanks for your reply.
>>>
>>>
>>>
>>>
>>> On Thu, May 23, 2019, 10:58 PM Reinis Rozitis <r@roze.lv> wrote:
>>>
>>>> > Instead of IP address, if we use FQDN with https, do we have to
>>>> validate the SSL certificate on Proxy_Pass?.
>>>>
>>>> By default the certificate validation is turned off (and nginx just
>>>> uses the ssl for traffic encryption).
>>>> If needed you can enable it with proxy_ssl_verify on; (
>>>> http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_ssl_verify
>>>> )
>>>>
>>>>
>>>> > Due to IP address, multiple sites on the server Nginx access log
>>>> logging the same requests.
>>>>
>>>> If you do the logging on the backend server (and there are multiple
>>>> virtualhosts) and proxy_pass is via http://ip, then you need/have to
>>>> pass also the Host header.
>>>>
>>>> Either by passing the Host header from original request:
>>>>
>>>> proxy_set_header Host $host;
>>>>
>>>> or you can specify a custom one:
>>>>
>>>> proxy_set_header Host "some.domain";
>>>>
>>>>
>>>>
>>>> > Is the above Nginx config, correct way of doing it?.
>>>>
>>>> Depends on your setup and what you want to achieve.
>>>>
>>>>
>>>> For example if your location blocks match the request on the backend
>>>> you can omit the URI in the proxy_pass directive:
>>>>
>>>> location /abc {
>>>> proxy_pass https://1.1.1.1;
>>>> }
>>>>
>>>> rr
>>>>
>>>> _______________________________________________
>>>> nginx mailing list
>>>> nginx@nginx.org
>>>> http://mailman.nginx.org/mailman/listinfo/nginx
>>>>
>>>
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Proxy Pass

Sathish Kumar May 23, 2019 08:36AM

RE: Proxy Pass

Reinis Rozitis May 23, 2019 11:00AM

Re: Proxy Pass

Sathish Kumar May 23, 2019 07:36PM

Re: Proxy Pass

Sathish Kumar May 23, 2019 08:06PM

Re: Proxy Pass

Sathish Kumar May 23, 2019 08:08PM

Re: Proxy Pass

Sathish Kumar May 23, 2019 09:26PM

Re: Proxy Pass

Francis Daly May 24, 2019 08:44AM

Re: Proxy Pass

Sathish Kumar May 24, 2019 08:56AM

Re: Proxy Pass

Francis Daly May 24, 2019 06:12PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 213
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready