Can't get subdomain to work nginx, debian 9

ralphot

Member
Credits
253
I have this in sites-available for the subdomain (there are two others, https://www.webshooter.se and http://www.webshooter.se):
## For support.webshooter.se subdomain
server {
listen 80;
listen [::]:80;
server_name support.webshooter.se;
root /var/www/support.webshooter.se;
index index.html index.php;
}
and it's linked to sites-enabled.

Have put this in the /etc/hosts file:
127.0.1.1 support.webshooter.se
When I ping locally:
[email protected]:/etc# ping support.webshooter.se
PING support.webshooter.se (127.0.1.1) 56(84) bytes of data.
64 bytes from ws02 (127.0.1.1): icmp_seq=1 ttl=64 time=0.051 ms
64 bytes from ws02 (127.0.1.1): icmp_seq=2 ttl=64 time=0.051 ms

But "Server not found" in browser. http://support.webshooter.se

What do I miss?
 


f33dm3bits

Gold Member
Gold Supporter
Credits
24,128
You probably forgot to open port 80 in your firewall?
 

f33dm3bits

Gold Member
Gold Supporter
Credits
24,128
From the system where you added the hosts file entry can you try doing the following requests and share the output?
Code:
curl -I support.webshooter.se
curl -I support.webshooter.se/index.php
curl -I support.webshooter.se/index.html
 

ralphot

Member
Credits
253
[email protected]:/var/www# curl -I support.webshooter.se
HTTP/1.1 200 OK
Server: nginx/1.18.0 (Ubuntu)
Date: Mon, 14 Jun 2021 20:05:37 GMT
Content-Type: application/octet-stream
Content-Length: 180
Last-Modified: Sat, 12 Jun 2021 20:10:10 GMT
Connection: keep-alive
ETag: "60c514a2-b4"
Accept-Ranges: bytes

[email protected]:/var/www# curl -I support.webshooter.se/index.php
HTTP/1.1 200 OK
Server: nginx/1.18.0 (Ubuntu)
Date: Mon, 14 Jun 2021 20:06:54 GMT
Content-Type: application/octet-stream
Content-Length: 180
Last-Modified: Sat, 12 Jun 2021 20:10:10 GMT
Connection: keep-alive
ETag: "60c514a2-b4"
Accept-Ranges: bytes

[email protected]:/var/www# curl -I support.webshooter.se/index.html
HTTP/1.1 404 Not Found
Server: nginx/1.18.0 (Ubuntu)
Date: Mon, 14 Jun 2021 20:08:30 GMT
Content-Type: text/html
Content-Length: 162
Connection: keep-alive

I have a index.php no .html in the support page.
 
Last edited:

ralphot

Member
Credits
253
I have also another "subdomain" on the same server:
[email protected]:/etc# curl -I http://www.webshooter.se/index.html
HTTP/1.1 200 OK
Server: nginx/1.18.0 (Ubuntu)
Date: Mon, 14 Jun 2021 21:10:27 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 1770
Last-Modified: Sun, 06 Jun 2021 14:43:12 GMT
Connection: keep-alive
ETag: "60bcdf00-6ea"
X-Frame-Options: SAMEORIGIN
Accept-Ranges: bytes

This works and the difference from the others is: X-Frame-Options: SAMEORIGIN
 
Last edited:

f33dm3bits

Gold Member
Gold Supporter
Credits
24,128
[email protected]:/var/www# curl -I support.webshooter.se
HTTP/1.1 200 OK
Server: nginx/1.18.0 (Ubuntu)
Date: Mon, 14 Jun 2021 20:05:37 GMT
Content-Type: application/octet-stream
Content-Length: 180
Last-Modified: Sat, 12 Jun 2021 20:10:10 GMT
Connection: keep-alive
ETag: "60c514a2-b4"
Accept-Ranges: bytes

[email protected]:/var/www# curl -I support.webshooter.se/index.php
HTTP/1.1 200 OK
Server: nginx/1.18.0 (Ubuntu)
Date: Mon, 14 Jun 2021 20:06:54 GMT
Content-Type: application/octet-stream
Content-Length: 180
Last-Modified: Sat, 12 Jun 2021 20:10:10 GMT
Connection: keep-alive
ETag: "60c514a2-b4"
Accept-Ranges: bytes

[email protected]:/var/www# curl -I support.webshooter.se/index.html
HTTP/1.1 404 Not Found
Server: nginx/1.18.0 (Ubuntu)
Date: Mon, 14 Jun 2021 20:08:30 GMT
Content-Type: text/html
Content-Length: 162
Connection: keep-alive

I have a index.php no .html in the support page.
Looking at this output the webserver isn't the problem:
1. You get an OK/200 back which is good.
2. You also get an OK/200 back.
3. You get an 404/Not found back since the file doesn't exist but it is a response from the webserver so it's working as expected.

I think the problem is somewhere else, also check the log file of the subdomain that may give you some more information.
 
Last edited:

ralphot

Member
Credits
253
Looking at this output the webserver isn't the problem:
1. You get an OK/200 back which is good.
2. You also get an OK/200 back.
3. You get an 404/Not found back since the file doesn't exist but it is a response from the webserver so it's working as expected.

I think the problem is somewhere else, also check the log file of the subdomain that may give you some more information.
log file of the subdomain? Where can I find that? What I have in /var/log/nginx is: 0 Jun 15 06:25 webshooter.se-error.log empty and nothin comes there if I update support.webshooter.se. Strange...
 

ralphot

Member
Credits
253
Sorry, han no error enabled in the sites-enable file for the support-page. Have that now but no errors occur when updating page. Very odd.
 
Last edited:

f33dm3bits

Gold Member
Gold Supporter
Credits
24,128
What does: X-Frame-Options: SAMEORIGIN means that comes with the working subdomain?
That has nothing to do with the problem since that's just a header, that's usually defined in the virtualhost of the subdomain.
log file of the subdomain? Where can I find that? What I have in /var/log/nginx is: 0 Jun 15 06:25 webshooter.se-error.log empty and nothin comes there if I update support.webshooter.se. Strange...
Usually you define a separate log file per virtualhost or subdomain, if you haven't done than that it probably goes all in the same log file.

Is support.webshooter.se on the same server as the other domain you mentioned, that way I can try adding it to my hosts file.
Code:
www.webshooter.se.    3600    IN    A    194.54.164.156
 

ralphot

Member
Credits
253
I have a resolv.conf contains:
nameserver 127.0.0.53
options edns0
Thank you for taking time to help me...:)
 
Last edited:

f33dm3bits

Gold Member
Gold Supporter
Credits
24,128
If I add this to my hosts file.
Code:
194.54.164.156 support.webshooter.se
And then the page loads.
2021-06-15_11_58_51.jpg
 
$100 Digital Ocean Credit
Get a free VM to test out Linux!

Members online


Top