Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

NGINX using server_name twice for all requests, resuling in 404

$
0
0
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?

Viewing all articles
Browse latest Browse all 4759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>