How to Configure Nginx VirtualHost in OpenSUSE
To Configure Nginx VirtualHost in OpenSUSE
Virtual Hosting is a technique for hosting multiple domains on a single web server. There are two types of Virtual Hosting - Name based and IP based. The former enables hosting multiple sites on the same IP address, and the latter can let a user to have different IP address for each site.
For the Nginx installation
visit https://www.linuxhelp.com/how-to-install-nginx-web-server-in-opensuse/
To Configure Nginx VirtualHost
The initial step is to get into the web root directory and create two directories under the document root directory.
linuxhelp:~ # cd /srv/www/htdocs/ linuxhelp:/srv/www/htdocs # mkdir sites1 sites2
Once the directories are created, open the sites1 directory. Create a file with text in it. Repeat the same for the sites2 directory. Use the following command for doing it.
linuxhelp:/srv/www/htdocs/site1 # vim index.html
Now create a separate directory on nginx configuration with the following command.
linuxhelp:~ # mkdir /etc/nginx/sites
After that, use the following command to create two new virtual host configuration files under sites directory.
linuxhelp:/etc/nginx/sites # touch test1.conf test2.conf
Now open the newly created test1.conf file and configure it as follows. Repeat the same procedure for the other file.
linuxhelp:/etc/nginx/sites # vim test1.conf
server{
listen 80
server_name linuxhelp1.com www.linuxhelp1.com
location /{
root /var/www/htdocs/sites1
index index.html
}
}
After configuring the above two files, use the following command to open the Nginx configuration file and edit it accordingly.
linuxhelp:/etc/nginx # vim nginx.conf
http {
include mime.types
include /etc/nginx/sites/*.conf
default_type application/octet-stream
Now issue the following command to check the configuration status of Nginx
linuxhelp:/etc/nginx # nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Once the configuration status is checked, edit the host file.
linuxhelp:~ # vim /etc/hosts
192.168.5.126 www.linuxhelp1.com
192.168.5.126 www.linuxhelp2.com
Once it is done, invoke the following command for restarting Nginx service.
linuxhelp:~ # systemctl restart nginx.service
After Nginx is restarted, open the browser and navigate to the first virtual domain by typing http://www.linuxhelp1.com. The browser displays the content of that particular file as follows.
Now to check the second virtual domain, type http://www.linuxhelp2.com and see its content.
You can deploy the same method to create multiple domains.
*NGINX Plus is released approximately quarterly; check the NGINX Plus release details. Updates are sent to all registered users of NGINX Plus.
Round-robin and weighted round-robin
Least-connected and weighted least-connected
Least-time and weighted least-time
Source-IP hash-based, and a weighted one
When you run two copies of the software on two different physical or virtual servers, that also counts as two instances.
Most DR deployments will require two instances per location, even if one instance is ‘passive’