D
D
Danya Kozlovskiy2021-09-28 01:43:07
linux
Danya Kozlovskiy, 2021-09-28 01:43:07

Why is the site not opening by domain on a virtual machine in linux?

Hello, habriki, I recently started diving into DevOps and decided to raise my server to nginx using YouTube guides. I did everything step by step, but something went wrong. The site is not given by domain (I hope I called it correctly) mysite.dev and through 192.168.1.71 everything works if you drive it into the browser not on a virtual machine (which is enp0s3). If I add the line 192.168.1.71 mysite.dev to /etc/hosts, then it returns html via curl from the virtual machine, but not through the browser on my PC.
What I did:
1. I downloaded virtual box and installed Ubuntu server 20 there. 2. I downloaded
all sorts of nginx packages and the like.
3. Downloaded the ufw firewall, added there:

OpenSSH                    ALLOW       Anywhere                  
Nginx Full                 ALLOW       Anywhere                  
Nginx HTTP                 ALLOW       Anywhere                  
Nginx HTTPS                ALLOW       Anywhere                  
33555                      ALLOW       Anywhere                  
443                        ALLOW       Anywhere                  
80                         ALLOW       Anywhere                  
OpenSSH (v6)               ALLOW       Anywhere (v6)             
Nginx Full (v6)            ALLOW       Anywhere (v6)             
Nginx HTTP (v6)            ALLOW       Anywhere (v6)             
Nginx HTTPS (v6)           ALLOW       Anywhere (v6)             
33555 (v6)                 ALLOW       Anywhere (v6)             
443 (v6)                   ALLOW       Anywhere (v6)             
80 (v6)                    ALLOW       Anywhere (v6)

4. Added to /var/www/mysite.dev /html index.html with markup.
5. Added a config for it to /etc/nginx/sites-avaliable mysite.dev.conf and linked it to /etc/nginx/sites-enable/:
server {
   listen 80;
   listen [::]:80;

   root /var/www/mysite.dev/html;
   index index.html index.htm;

   server_name mysite.dev;

   location / {
       try_files $uri $uri/ =404;
   }
}
.
6. If you try to get ssh through certbot, then it writes this (most likely because this is not a public domain, but you never know):
Certbot failed to authenticate some domains (authenticator: nginx). The Certificate Authority reported these problems:
  Domain: mysite.dev
  Type:   dns
  Detail: DNS problem: NXDOMAIN looking up A for mysite.dev  - check that a DNS record exists for this domain

Hint: The Certificate Authority failed to verify the temporary nginx configuration changes made by Certbot. Ensure the listed domains point to this nginx server and that it is accessible from the internet.

8.Config /etc/nginx/nginx.conf:
load_module modules/ngx_http_brotli_filter_module.so;
load_module modules/ngx_http_brotli_static_module.so;
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/*;

# Compression brotli 
    brotli              on;
    brotli_comp_level   6;
    brotli_static       on;
    brotli_types        text/xml image/svg+xml application/x-font-ttf image/vnd.microsoft.icon application/x-font-opentype application/json font/eot application/vnd.ms-fontobject application/javascript font/otf application/xml application/xhtml+xml text/javascript  application/x-javascript text/plain application/x-font-truetype application/xml+rss image/x-icon font/opentype text/css image/x-win-bitmap;

}


#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;
#	}
#}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Talyan, 2021-09-28
@morto

Well, firstly, judging by the question, you don’t fumble at all.
Secondly, you added a hostname for the address to /etc/hosts on the virtual machine. Congratulations, now the virtual machine knows about the mysite.dev host.
But your host machine knows nothing about this host. Add to C:/Windows/system32/drivers/etc/hosts the same line as in Linux.
God forbid me such a devops))

DevOps is a methodology for the active interaction of development specialists with information technology service specialists and the mutual integration of their...

That is, you first need to be able to be a developer, then also be a Linux administrator, and then maybe someday, look towards devops.
You are not that far away, you generally started from the end)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question