0

I have installed nginx version: nginx/1.17.10 (Ubuntu). The index page which is pointed by "default" configuration file in "sites-enabled" directory works properly. I have created another configuration file in "sites-enabled" called "test.com" and it looks as :

enter image description here

and

enter image description here

i have placed the index file in directory...

usr/share/nginx/test.com

I have edited the hosts configuration in

/etc/hosts

enter image description here

now when i do curl test.com i am getting 404 not found error as

enter image description here

8
  • According your config you have set virtual host test.com with a server_name directive. Which is saying that it will respond only when you will pass the correct host header in your request. Just add -H "Host: test.com" to curl command to pass correct host header. Commented Jun 5, 2020 at 12:16
  • sir please explain Commented Jun 5, 2020 at 12:18
  • If you do not pass the correct host header then the default config (default site) will take in place and you probably can get 404 or Nginx default page, it depends of the default config. See details at nginx.org/en/docs/http/server_names.html Commented Jun 5, 2020 at 12:24
  • i am getting curl:no url specified. Commented Jun 5, 2020 at 13:05
  • Use this one: curl -H "Host: test.com" --URL "http://test.com" Commented Jun 5, 2020 at 13:12

1 Answer 1

1

The solution is to change:

root /usr/share/nginx/test.com;

and

try_files $uri $uri/index.html $uri.html =404;

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.