A
A
arenchilingaryan2020-07-17 15:11:15
Nginx
arenchilingaryan, 2020-07-17 15:11:15

How to proxy through ngnix?

have a domain name. There is a server. I can't make ngnix redirect to the server when requesting a domain name.

server ip on node - server-nodejs
domain - domain.com

/etc/nginx/sites-available/default

server {
listen 443 ssl domain.com www.domain.com;
listen [::]:443 ssl domain.com www.domain.com;
ssl_certificate /etc/nginx/ssl/domain.com.crt;
ssl_certificate_key /etc/nginx/ssl/domain.com.key;
root /var/www/www-root/data/www/domain.com/;
index index.html;
server_name server-nodejs;
error_page 500 502 503 504 /50x.html;
error_page 400 401 402 403 404 /40x.html;
location = /50x.html {
root /var/www/errors;
}
location = /40x.html {
root /var/www/errors;
}
return 301 https://$server_name$request_uri ;
location / {
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $https_host;
proxy_pass server-nodejs:5000 ;
try_files $uri $uri/ =404;
}
location /nginx/ {
root /var/www/;
autoindex off;
}
}

What is wrong with this file? And do I poke the file at all in this situation?

In the network request, for some reason, it redirects, as I understand it, to 443, even though I need to 5000, where the

network request node is running:
Remote Address: server-nodejs: 443

Thanks in advance for your answer!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2020-07-17
@q2digger

Because the line
return 301 .... is
superfluous here. Remove it, restart nginx and try

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question