Skip Navigation

Currently trying to get my head wrapped around NGINX. What do i do wrong?

I've been trying to learn NGINX for a bit now. I tried to make a simple configuration to redirect a subdomain to a specific IP:PORT. However, I fail to manage to make it work properly. Currently, NGINX seems to redirect every request coming into the server to that specific IP:PORT, while also returning the internal IP of the server instead of the proper domain name.

Here's the config :

worker_processes 1;

events {
worker_connections 1024;
}

http {
server {
listen 80;
server_name service.domain.info;

location / {
proxy_pass http://192.168.1.55:81;
proxy_http_version 1.1;
proxy_set_header X-Forwarded-Host $host:$server_port;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}

server {
listen 443 ssl;
server_name service.domain.info;
proxy_send_timeout 330s;
proxy_read_timeout 330s;
ssl_certificate c:/folder/folder/webserver-cert-public.crt;
ssl_certificate_key c:/folder/folder/webserver-cert-private.key;
ssl_session_cache shared:WEBSSL:10m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;

location / {
proxy_pass https://192.168.1.55:444;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host:$server_port;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
}

I compared it a bit to other examples i could find on the internet, and couldn't figure out why was wrong. The config should just redirect https://service.domain.info to https://192.168.1.55:444 and http://service.domain.info to http://192.168.1.55:81

If anyone who knows about it more than I do could help, I would appreciate it. Thanks.

1
1 comments