how to seperate redirection of url coming from internet and localhost on 443
June 11, 2023 08:38AM
Hello Good day everyone,
I need some guidance if you can kindly help.

I have set up a nginx server to reverse proxy at 443

I have set a pagekite configurations too to expose my server online
It was all well, until i thought i should introduce the https ssl thing too

Now, im able to redirect the incoming request in local host to the https port.

But when opened from internet , the redirection is moving to the localhost only? Where as it should have be stayed on the same host

This is the whole configuration

server {
listen 80;
server_name localhost;

location /.well-known/acme-challenge/ {
root D:\Development\Certbot\acme;
}
return 308 https://$server_name$request_uri;
}


# HTTPS server
#
server {
listen 443 ssl;
server_name connekted.pagekite.me;

ssl_certificate D:\Development\Nginx\\nginx-1.25.0\acme\\nginx.crt;
ssl_certificate_key D:\Development\Nginx\\nginx-1.25.0\acme\\nginx.key;

index house.html;

#ssl_session_cache shared:SSL:1m;
#ssl_session_timeout 5m;

#ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;

location /.well-known/acme-challenge/ {
root D:\Development\Certbot\acme;
}


location /house {
proxy_pass https://192.168.0.6:1880/house;
root /html;
#index.html index.htm;
proxy_redirect https://192.168.0.6:1880/house https://$host/house;

proxy_set_header Host $host;
##added recently
proxy_set_header Referer $http_referer;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;

proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

location /images
{
root /images/pictures;
}

}


###HTTPS 2


server {
listen 443 ssl;
server_name localhost;

ssl_certificate D:\Development\Nginx\\nginx-1.25.0\acme\\nginx.crt;
ssl_certificate_key D:\Development\Nginx\\nginx-1.25.0\acme\\nginx.key;

index house.html;

#ssl_session_cache shared:SSL:1m;
#ssl_session_timeout 5m;

#ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;



location /.well-known/acme-challenge/ {
root D:\Development\Certbot\acme;
}


location /house {
proxy_pass https://192.168.0.6:1880/house;
root /html;
#index.html index.htm;
proxy_redirect https://192.168.0.6:1880/house https://$host/house;

proxy_set_header Host $host;
proxy_set_header Referer $http_referer;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;

proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}

Please help how to correctly configure it
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 193
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