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

Wikipedia:Vital articles Мазмуну Biography - Өмүр баян Philosophy and psychology - Философия жана психология Religion - Дин Social sciences - Коомдук илимдер Language and literature - Тил жана адабият Science - Илим Technology - Технология Arts and recreation - Искусство жана эс алуу History and geography - Тарых жана география Навигация менюсу

Bruxelas-Capital Índice Historia | Composición | Situación lingüística | Clima | Cidades irmandadas | Notas | Véxase tamén | Menú de navegacióneO uso das linguas en Bruxelas e a situación do neerlandés"Rexión de Bruxelas Capital"o orixinalSitio da rexiónPáxina de Bruselas no sitio da Oficina de Promoción Turística de Valonia e BruxelasMapa Interactivo da Rexión de Bruxelas-CapitaleeWorldCat332144929079854441105155190212ID28008674080552-90000 0001 0666 3698n94104302ID540940339365017018237

What should I write in an apology letter, since I have decided not to join a company after accepting an offer letterShould I keep looking after accepting a job offer?What should I do when I've been verbally told I would get an offer letter, but still haven't gotten one after 4 weeks?Do I accept an offer from a company that I am not likely to join?New job hasn't confirmed starting date and I want to give current employer as much notice as possibleHow should I address my manager in my resignation letter?HR delayed background verification, now jobless as resignedNo email communication after accepting a formal written offer. How should I phrase the call?What should I do if after receiving a verbal offer letter I am informed that my written job offer is put on hold due to some internal issues?Should I inform the current employer that I am about to resign within 1-2 weeks since I have signed the offer letter and waiting for visa?What company will do, if I send their offer letter to another company