D
D
Denis2019-10-18 13:16:59
Nginx
Denis, 2019-10-18 13:16:59

Why do HTTP Headers disappear when nginx redirects?

There is a controller and a bunch of clients with sensors. All clients connect to the controller at the old-site.ru
address. Sensors began to arrive that connect to the controller at the new address new-site.ru , and no one is going to change the controller address yet, because don't know how.
The idea immediately came to mind to send new sensors to the server with nginx, where to organize a redirect from new-site.ru to old-site.ru . It seems nothing complicated, but there were problems.
The presence of http headers is important for the controller:
x-citron-mac : aa:33:99:ff:11:dd
Host : old-site.ru

In the absence of these headers or inconsistency, the sensor displays in its console:

[NETWORK] >> Error: void QtvDataStorageLoaderPrivate::_q_networkReplyFinished() parsing error in "http://new-site.ru/auth?mac=aa:33:99:ff:11:dd&Ver=334.15&ip=192.168.10.33" : "Start-end tags mismatch"

If successful, the sensor should receive some kind of xml file from the controller...
When analyzing the nginx logs, they realized that http headers are not transmitted, and new-site.ru is substituted in the Host header, of course, the controller does not issue anything and blocks such requests.
Tried everything possible to redirect to nginx, nothing helps
server {
listen 192.168.1.3:80;
server_name new-site.ru;
#rewrite ^/(.*)$ http://old-site.ru/$1 permanent;
#rewrite ^/(.*)$ http://old-site.ru$1 permanent;
#return 302 http://old-site.ru$request_uri;
#return 301 $scheme://old-site.ru$request_uri;
return 301 http://old-site.ru$/request_uri;
#rewrite ^ $scheme://old-site.ru.net;
}

Tell me, maybe you need to use some special parameters in the nginx redirect settings?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
ky0, 2019-10-18
@Rentable

Do a reverse proxy, not a redirect. And substitute the title for the backend:
proxy_set_header Host old-site.ru;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question