A
A
Artyom2021-04-05 20:02:21
Nginx
Artyom, 2021-04-05 20:02:21

I get an invalid host header nodejs error, how to fix it?

I am deploying a large application written in React to the server. Server on Ubuntu. And everything would be fine, but when I go through the domain (nginx proxies the request to the React application), an invalid host header appears on the screen.
I am not using webpack.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Karabanov, 2021-04-05
@karabanov

I suspect that the word redirects means proxies. In this case, the proxy_set_header
directive is missing. As a result, it should turn out something like this:

location / {
    proxy_set_header Host $host;
    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_pass http://localhost:8000/;
}

If you showed your config, you wouldn't have to guess...

N
nutkatuz, 2021-04-06
@nutkatuz

but aren't the headers for the server written in the top block?... doesn't matter?.. (sorry)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question