Welcome! Log In Create A New Profile

Advanced

NGINX using server_name twice for all requests, resuling in 404

Posted by karlito96 
NGINX using server_name twice for all requests, resuling in 404
August 22, 2020 02:01PM
Hello all,

Completely new to both web servers and nginx in particular.
I've been trying to host my static web page that I've built with hugo. I've tested it locally using hugo server and all the contents are loading properly.

When I upload my site to /var/www/mysite/ and try to serve it with nginx, only the initial index.html within my site dir is loaded. Each other request is 404_not found.
Reason being is each other resource besides the main index.html is being referred to by nginx as /server_name/server_name/...

Example I have an 'About' tab, that should be served from http://anna.home/about however nginx is redirecting to http://anna.home/anna.home/about which doesn't exist hence the 404.

I'm pretty sure it's a simple fix for somebody who's touched nginx before but I've been pulling my hair due to this one for a good few hours..


*/var/www/anna.home*

-rwxr-xr-x 1 opasen users 7016 Aug 22 18:25 404.html
drwxr-xr-x 3 opasen users 4096 Aug 22 18:25 about
drwxr-xr-x 2 opasen users 4096 Aug 22 18:25 categories
drwxr-xr-x 2 opasen users 4096 Aug 22 18:25 contact
drwxr-xr-x 4 opasen users 4096 Aug 22 18:25 dist
drwxr-xr-x 2 opasen users 4096 Aug 22 18:25 images
-rwxr-xr-x 1 opasen users 12014 Aug 22 18:25 index.html
-rwxr-xr-x 1 opasen users 5548 Aug 22 18:25 index.xml
drwxr-xr-x 9 opasen users 4096 Aug 22 18:25 post
-rwxr-xr-x 1 opasen users 111 Aug 22 18:25 robots.txt
-rwxr-xr-x 1 opasen users 2256 Aug 22 18:25 sitemap.xml
drwxr-xr-x 3 opasen users 4096 Aug 22 18:25 tags


*/var/www/anna.home/about*

-rwxr-xr-x 1 opasen users 9023 Aug 22 18:25 index.html
-rwxr-xr-x 1 opasen users 485 Aug 22 18:25 index.xml
drwxr-xr-x 3 opasen users 4096 Aug 22 18:25 page


*NGINX version && nginx.conf*

nginx version: nginx/1.18.0


worker_processes 2;

events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;

server {
server_tokens off;
listen anna.home:80;
server_name anna.home;
root /var/www/anna.home;

location / {
}

location /images {
}

location /about {
}

location /articles {
}

location /contact {
}

error_page 500 502 503 504 /50x.html;

location = /50x.html {
root html;
}
}
}


Any help will be much appreciated. Do let me know if I've not provided important/crucial info.

Thanks,
me


PS: Does anybody know if [b]bulletin[/b] [i]baord[/i] [code]code[/code] works here, and if not how do you guys achieve formatting?



Edited 2 time(s). Last edit at 08/22/2020 02:05PM by karlito96.
Re: NGINX using server_name twice for all requests, resuling in 404
August 22, 2020 02:22PM
wrong sub-section of forum.. apoliogies.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 82
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready