Cannot add second domain to Nginx serverTrouble with nginx and serving from multiple directories under the same domainServing static sites from S3 with nginxhow to set the nginx root path to a direcoty outside the ngnix dirNginx config file only working for ''/"Can not change nginx 1.2.5 default websiteNginx autoindex featureNginx ignores my second server directivenginx configuration troubleCodeIgniter nginx rewrite rules for i8ln URL'sWhy Nginx calls for invalid certificate in non-existent subdomains just to redirect to 404?

Can I ask the recruiters in my resume to put the reason why I am rejected?

Languages that we cannot (dis)prove to be Context-Free

Are the number of citations and number of published articles the most important criteria for a tenure promotion?

Test whether all array elements are factors of a number

TGV timetables / schedules?

Why are electrically insulating heatsinks so rare? Is it just cost?

Modeling an IPv4 Address

How do we improve the relationship with a client software team that performs poorly and is becoming less collaborative?

Do I have a twin with permutated remainders?

How do I create uniquely male characters?

Collect Fourier series terms

Why Is Death Allowed In the Matrix?

Can an x86 CPU running in real mode be considered to be basically an 8086 CPU?

tikz: show 0 at the axis origin

"You are your self first supporter", a more proper way to say it

Can I make popcorn with any corn?

What is the word for reserving something for yourself before others do?

Why not use SQL instead of GraphQL?

Mathematical cryptic clues

can i play a electric guitar through a bass amp?

How much RAM could one put in a typical 80386 setup?

What are the differences between the usage of 'it' and 'they'?

How can I make my BBEG immortal short of making them a Lich or Vampire?

Maximum likelihood parameters deviate from posterior distributions



Cannot add second domain to Nginx server


Trouble with nginx and serving from multiple directories under the same domainServing static sites from S3 with nginxhow to set the nginx root path to a direcoty outside the ngnix dirNginx config file only working for ''/"Can not change nginx 1.2.5 default websiteNginx autoindex featureNginx ignores my second server directivenginx configuration troubleCodeIgniter nginx rewrite rules for i8ln URL'sWhy Nginx calls for invalid certificate in non-existent subdomains just to redirect to 404?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I have a local macOS server with nginx setup to host one domain: ogli.codes (which currently works fine).

Now, I want to add a second domain: api.ogli.codes. For now, I'd just like to show a simple hello-world-index.html file.



This is my configuration file for ogli.codes:



server 
listen 80;
server_name ogli.codes;
root html/ogli.codes;
index index.html;



So I duplicated that file and simply changed the directory and the server name:



server 
listen 80;
server_name api.ogli.codes;
root html/api.ogli.codes;
index index.html;



Then, I added the alias to /sites-enabled and reloaded nginx:



sudo nginx -s stop && sudo nginx


...and added the folder api.ogli.codes in the same directory as ogli.codes is in: /usr/local/var/www/ (yes, this is the correct path, as html points there directly.

Inside that folder, I created a simple index.html file saying "It works!"



Now, when I open ogli.codes in the browser, it works just fine, but heading over to api.ogli.codes gives me a 404 not found.

So: the domain properly resolves to my server's IP, but I cannot see my site.



What's also interesting is that I tried to support www.ogli.codes in the first configuration file, by changing the server_name line to:



server_name ogli.codes www.ogli.codes;


After reloading nginx, I also cannot reach www.ogli.codes. Might those issues have the same root?



What's wrong here?










share|improve this question







New contributor




LinusGeffarth is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • Check the error log.

    – Michael Hampton
    Apr 3 at 16:01











  • @MichaelHampton this is the only thing I see: 2019/04/03 17:49:43 [notice] 42807#0: signal process started and 2019/04/03 18:00:50 [error] 42811#0: *15 open() "/usr/local/Cellar/nginx/1.15.9/html/ogli.codes/robots.txt" failed (2: No such file or directory), client: 94.130.167.104, server: ogli.codes, request: "GET /robots.txt HTTP/1.1", host: "ogli.codes"

    – LinusGeffarth
    Apr 3 at 16:07












  • That means your root directive is not pointing to the directory you think it is.

    – Michael Hampton
    Apr 3 at 16:08











  • I just tested changing sth. in the index.html for ogli.codes (the once that works) and I immediately saw the change on the server when refreshing the page. Note that this only says robots.txt is missing, which is true, but shouldn't be related to my question.

    – LinusGeffarth
    Apr 3 at 16:09












  • api.ogli.codes points to IP 18.191.173.167 while ogli.codes185.10.148.214. Probably you should change your DNS

    – Alexey Ten
    Apr 3 at 23:00

















0















I have a local macOS server with nginx setup to host one domain: ogli.codes (which currently works fine).

Now, I want to add a second domain: api.ogli.codes. For now, I'd just like to show a simple hello-world-index.html file.



This is my configuration file for ogli.codes:



server 
listen 80;
server_name ogli.codes;
root html/ogli.codes;
index index.html;



So I duplicated that file and simply changed the directory and the server name:



server 
listen 80;
server_name api.ogli.codes;
root html/api.ogli.codes;
index index.html;



Then, I added the alias to /sites-enabled and reloaded nginx:



sudo nginx -s stop && sudo nginx


...and added the folder api.ogli.codes in the same directory as ogli.codes is in: /usr/local/var/www/ (yes, this is the correct path, as html points there directly.

Inside that folder, I created a simple index.html file saying "It works!"



Now, when I open ogli.codes in the browser, it works just fine, but heading over to api.ogli.codes gives me a 404 not found.

So: the domain properly resolves to my server's IP, but I cannot see my site.



What's also interesting is that I tried to support www.ogli.codes in the first configuration file, by changing the server_name line to:



server_name ogli.codes www.ogli.codes;


After reloading nginx, I also cannot reach www.ogli.codes. Might those issues have the same root?



What's wrong here?










share|improve this question







New contributor




LinusGeffarth is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • Check the error log.

    – Michael Hampton
    Apr 3 at 16:01











  • @MichaelHampton this is the only thing I see: 2019/04/03 17:49:43 [notice] 42807#0: signal process started and 2019/04/03 18:00:50 [error] 42811#0: *15 open() "/usr/local/Cellar/nginx/1.15.9/html/ogli.codes/robots.txt" failed (2: No such file or directory), client: 94.130.167.104, server: ogli.codes, request: "GET /robots.txt HTTP/1.1", host: "ogli.codes"

    – LinusGeffarth
    Apr 3 at 16:07












  • That means your root directive is not pointing to the directory you think it is.

    – Michael Hampton
    Apr 3 at 16:08











  • I just tested changing sth. in the index.html for ogli.codes (the once that works) and I immediately saw the change on the server when refreshing the page. Note that this only says robots.txt is missing, which is true, but shouldn't be related to my question.

    – LinusGeffarth
    Apr 3 at 16:09












  • api.ogli.codes points to IP 18.191.173.167 while ogli.codes185.10.148.214. Probably you should change your DNS

    – Alexey Ten
    Apr 3 at 23:00













0












0








0








I have a local macOS server with nginx setup to host one domain: ogli.codes (which currently works fine).

Now, I want to add a second domain: api.ogli.codes. For now, I'd just like to show a simple hello-world-index.html file.



This is my configuration file for ogli.codes:



server 
listen 80;
server_name ogli.codes;
root html/ogli.codes;
index index.html;



So I duplicated that file and simply changed the directory and the server name:



server 
listen 80;
server_name api.ogli.codes;
root html/api.ogli.codes;
index index.html;



Then, I added the alias to /sites-enabled and reloaded nginx:



sudo nginx -s stop && sudo nginx


...and added the folder api.ogli.codes in the same directory as ogli.codes is in: /usr/local/var/www/ (yes, this is the correct path, as html points there directly.

Inside that folder, I created a simple index.html file saying "It works!"



Now, when I open ogli.codes in the browser, it works just fine, but heading over to api.ogli.codes gives me a 404 not found.

So: the domain properly resolves to my server's IP, but I cannot see my site.



What's also interesting is that I tried to support www.ogli.codes in the first configuration file, by changing the server_name line to:



server_name ogli.codes www.ogli.codes;


After reloading nginx, I also cannot reach www.ogli.codes. Might those issues have the same root?



What's wrong here?










share|improve this question







New contributor




LinusGeffarth is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I have a local macOS server with nginx setup to host one domain: ogli.codes (which currently works fine).

Now, I want to add a second domain: api.ogli.codes. For now, I'd just like to show a simple hello-world-index.html file.



This is my configuration file for ogli.codes:



server 
listen 80;
server_name ogli.codes;
root html/ogli.codes;
index index.html;



So I duplicated that file and simply changed the directory and the server name:



server 
listen 80;
server_name api.ogli.codes;
root html/api.ogli.codes;
index index.html;



Then, I added the alias to /sites-enabled and reloaded nginx:



sudo nginx -s stop && sudo nginx


...and added the folder api.ogli.codes in the same directory as ogli.codes is in: /usr/local/var/www/ (yes, this is the correct path, as html points there directly.

Inside that folder, I created a simple index.html file saying "It works!"



Now, when I open ogli.codes in the browser, it works just fine, but heading over to api.ogli.codes gives me a 404 not found.

So: the domain properly resolves to my server's IP, but I cannot see my site.



What's also interesting is that I tried to support www.ogli.codes in the first configuration file, by changing the server_name line to:



server_name ogli.codes www.ogli.codes;


After reloading nginx, I also cannot reach www.ogli.codes. Might those issues have the same root?



What's wrong here?







nginx mac-osx






share|improve this question







New contributor




LinusGeffarth is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




LinusGeffarth is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




LinusGeffarth is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Apr 3 at 15:56









LinusGeffarthLinusGeffarth

1086




1086




New contributor




LinusGeffarth is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





LinusGeffarth is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






LinusGeffarth is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • Check the error log.

    – Michael Hampton
    Apr 3 at 16:01











  • @MichaelHampton this is the only thing I see: 2019/04/03 17:49:43 [notice] 42807#0: signal process started and 2019/04/03 18:00:50 [error] 42811#0: *15 open() "/usr/local/Cellar/nginx/1.15.9/html/ogli.codes/robots.txt" failed (2: No such file or directory), client: 94.130.167.104, server: ogli.codes, request: "GET /robots.txt HTTP/1.1", host: "ogli.codes"

    – LinusGeffarth
    Apr 3 at 16:07












  • That means your root directive is not pointing to the directory you think it is.

    – Michael Hampton
    Apr 3 at 16:08











  • I just tested changing sth. in the index.html for ogli.codes (the once that works) and I immediately saw the change on the server when refreshing the page. Note that this only says robots.txt is missing, which is true, but shouldn't be related to my question.

    – LinusGeffarth
    Apr 3 at 16:09












  • api.ogli.codes points to IP 18.191.173.167 while ogli.codes185.10.148.214. Probably you should change your DNS

    – Alexey Ten
    Apr 3 at 23:00

















  • Check the error log.

    – Michael Hampton
    Apr 3 at 16:01











  • @MichaelHampton this is the only thing I see: 2019/04/03 17:49:43 [notice] 42807#0: signal process started and 2019/04/03 18:00:50 [error] 42811#0: *15 open() "/usr/local/Cellar/nginx/1.15.9/html/ogli.codes/robots.txt" failed (2: No such file or directory), client: 94.130.167.104, server: ogli.codes, request: "GET /robots.txt HTTP/1.1", host: "ogli.codes"

    – LinusGeffarth
    Apr 3 at 16:07












  • That means your root directive is not pointing to the directory you think it is.

    – Michael Hampton
    Apr 3 at 16:08











  • I just tested changing sth. in the index.html for ogli.codes (the once that works) and I immediately saw the change on the server when refreshing the page. Note that this only says robots.txt is missing, which is true, but shouldn't be related to my question.

    – LinusGeffarth
    Apr 3 at 16:09












  • api.ogli.codes points to IP 18.191.173.167 while ogli.codes185.10.148.214. Probably you should change your DNS

    – Alexey Ten
    Apr 3 at 23:00
















Check the error log.

– Michael Hampton
Apr 3 at 16:01





Check the error log.

– Michael Hampton
Apr 3 at 16:01













@MichaelHampton this is the only thing I see: 2019/04/03 17:49:43 [notice] 42807#0: signal process started and 2019/04/03 18:00:50 [error] 42811#0: *15 open() "/usr/local/Cellar/nginx/1.15.9/html/ogli.codes/robots.txt" failed (2: No such file or directory), client: 94.130.167.104, server: ogli.codes, request: "GET /robots.txt HTTP/1.1", host: "ogli.codes"

– LinusGeffarth
Apr 3 at 16:07






@MichaelHampton this is the only thing I see: 2019/04/03 17:49:43 [notice] 42807#0: signal process started and 2019/04/03 18:00:50 [error] 42811#0: *15 open() "/usr/local/Cellar/nginx/1.15.9/html/ogli.codes/robots.txt" failed (2: No such file or directory), client: 94.130.167.104, server: ogli.codes, request: "GET /robots.txt HTTP/1.1", host: "ogli.codes"

– LinusGeffarth
Apr 3 at 16:07














That means your root directive is not pointing to the directory you think it is.

– Michael Hampton
Apr 3 at 16:08





That means your root directive is not pointing to the directory you think it is.

– Michael Hampton
Apr 3 at 16:08













I just tested changing sth. in the index.html for ogli.codes (the once that works) and I immediately saw the change on the server when refreshing the page. Note that this only says robots.txt is missing, which is true, but shouldn't be related to my question.

– LinusGeffarth
Apr 3 at 16:09






I just tested changing sth. in the index.html for ogli.codes (the once that works) and I immediately saw the change on the server when refreshing the page. Note that this only says robots.txt is missing, which is true, but shouldn't be related to my question.

– LinusGeffarth
Apr 3 at 16:09














api.ogli.codes points to IP 18.191.173.167 while ogli.codes185.10.148.214. Probably you should change your DNS

– Alexey Ten
Apr 3 at 23:00





api.ogli.codes points to IP 18.191.173.167 while ogli.codes185.10.148.214. Probably you should change your DNS

– Alexey Ten
Apr 3 at 23:00










0






active

oldest

votes












Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "2"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);






LinusGeffarth is a new contributor. Be nice, and check out our Code of Conduct.









draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f961330%2fcannot-add-second-domain-to-nginx-server%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes








LinusGeffarth is a new contributor. Be nice, and check out our Code of Conduct.









draft saved

draft discarded


















LinusGeffarth is a new contributor. Be nice, and check out our Code of Conduct.












LinusGeffarth is a new contributor. Be nice, and check out our Code of Conduct.











LinusGeffarth is a new contributor. Be nice, and check out our Code of Conduct.














Thanks for contributing an answer to Server Fault!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f961330%2fcannot-add-second-domain-to-nginx-server%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to write a 12-bar blues melodyI-IV-V blues progressionHow to play the bridges in a standard blues progressionHow does Gdim7 fit in C# minor?question on a certain chord progressionMusicology of Melody12 bar blues, spread rhythm: alternative to 6th chord to avoid finger stretchChord progressions/ Root key/ MelodiesHow to put chords (POP-EDM) under a given lead vocal melody (starting from a good knowledge in music theory)Are there “rules” for improvising with the minor pentatonic scale over 12-bar shuffle?Confusion about blues scale and chords

What if the end-user didn't have the required library?What is setup.py?What is a clean, pythonic way to have multiple constructors in Python?What does Ruby have that Python doesn't, and vice versa?What is the reason for having '//' in Python?How do I create a namespace package in Python?How to package shared objects that python modules depend on?setuptools vs. distutils: why is distutils still a thing?Navigation in Windows 10 vs code not going to virtualenv library when the same library is installed at user levelPython create package for local usePackaging a project that uses multiple python versionsWhy is permission denied on pip install except for when “--user” is included at end of command?

Why did Thanos need his ship to help him in the battle scene?Which actor plays Thanos in the Avengers mid-credits scene?Are there economic implications portrayed in comics where the buildings and cities are ruined almost daily?Old X-Men comic where team travels to alien world with a ring-like sun that needs recharging?Why does Ego need help sleeping?Is there an objective answer to who “the strongest Avenger” is?How did Banner get unstuck?Why did Thanos get hit?How did Thanos (or anyone) know the Infinity Stones would give him this power?Did Thanos leave Eitri alive for his after-sales service?In Avengers 1, why does Thanos need Loki?