Welcome! Log In Create A New Profile

Advanced

Nginx serverblock for subdomain not working

Posted by Mithradantor 
Nginx serverblock for subdomain not working
July 24, 2020 04:16AM
Hey guys, I see no option for adding code blocks so sorry for the code not looking pritty! :(

I tried to follow some tutorials (and posts) on how to add a subdomain to nginx but unfortunately I am unable to get it working.

On my domainname's DNS we added a "A" record *.mydomain.com that forwards to the IP address of our server so that should be fine.

On our server we added a nginx block with the following data:

```server {

root /var/www/development.mydomain.com;
index index.html index.htm index.nginx-debian.html;

server_name development.mydomain.com;

location / {
try_files $uri $uri/ /index.html;
}

listen 80;
listen [::]:80;

}
```

I then tested the block, made a symlink, and then restarted nginx.

When I try to visit my website now, it will not show the HTML file that is inside my folder. Instead it shows a "NGINX is working" screen. White with black letters.

Also, in my directory is a file called index.html (made it myself). When I go to

development.mydomain.com/index.html it shows me a page cannot be found error.

Does anyone have a clue what might be wrong?

I am using Ubuntu 20 with NGINX. I just ran "sudo apt install nginx" so not sure which NGINX version I have but I am pritty sure it'll be the latest.

I deleted the default serverblock by the way so this shouldnt be overwriting my own server block.

When I run the command

```
nginx -t
```

this is the output:

```
# configuration file /etc/nginx/nginx.conf:
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
worker_connections 768;
# multi_accept on;
}

http {

##
# Basic Settings
##

sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;

server_names_hash_bucket_size 64;
# server_name_in_redirect off;

include /etc/nginx/mime.types;
default_type application/octet-stream;

##
# SSL Settings
##

ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;

##
# Logging Settings
##

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

##
# Gzip Settings
##

gzip on;

# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

##
# Virtual Host Configs
##

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}


#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}

# configuration file /etc/nginx/modules-enabled/50-mod-http-image-filter.conf:
load_module modules/ngx_http_image_filter_module.so;

# configuration file /etc/nginx/modules-enabled/50-mod-http-xslt-filter.conf:
load_module modules/ngx_http_xslt_filter_module.so;

# configuration file /etc/nginx/modules-enabled/50-mod-mail.conf:
load_module modules/ngx_mail_module.so;

# configuration file /etc/nginx/modules-enabled/50-mod-stream.conf:
load_module modules/ngx_stream_module.so;

# configuration file /etc/nginx/sites-enabled/development.mydomain.com.conf:
server {
listen 80;
listen [::]:80;

root /var/www/development.mydomain.com;
index index.html index.htm;

server_name development.mydomain.com www.development.mydomain.com;

location / {
try_files $uri $uri/ /index.html;
}
}
```
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 290
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready