I have made a website with one subdomain hosted on a local Raspberry Pi on Nginx in my house network.
I can access the subdomain on say :
sub.mydomain.com
But when I try and access the main site :
domain.com
I get redirected to :
domain.com/domain.com/domain.com/domain.com/domain.com/domain.com/domain.comdomain.comdomain.comdomain.comdomain.com/ ( and so on )
Here is my setup :
I am running this locally, so I am trying to see my own website so I am using a VPN which works for the subdomain but not the main page.
If I use domain.com/index.html
that works but it will not go from domain.com
to domain.com/index.html
automatically. ( it did this the last time I made a single - non subdomain - webpage site )
If I access this from my phone ( external network ) it all works great.
I would like to know why this is happening and how to fix it as the WordPress site cant be seen from me inside my network now.
Here is my Nginx config for domain.com :
server {
root /var/www/doamin.com;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
server_name doamin.com;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
location /custom/ {
proxy_pass http://localhost:1234;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
# # With php-cgi (or other tcp sockets):
# fastcgi_pass 127.0.0.1:9000;
}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/doamin.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/doamin.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = doamin.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80 default_server;
listen [::]:80 default_server;
server_name doamin.com;
return 404; # managed by Certbot
}
If possible please explain why it does this in as simple terms as possible , I would like to understand this better, networking and server setup like this is very new to me.