Webinoly is just the perfect tool for NGINX experts. Give it a try!
+1 vote
954 views
by Rookie

I disabled a site with

sudo site domain.com -off

When I do

sudo site -list

It would be great to see which sites are deactivated. Maybe you could use a different color (red?), or maybe you could use a + in front of the site name for active sites and a - in front of ones that are disabled, or perhaps just put "(off)" or "(disabled)" after domains that are currently deactivated.

Of course, this would not be shown when using the "raw" option.

Just an idea.

by Rookie

I am still working on my script. It works fine using the code I "borrowed" from Webinoly (below), except for cases where the site is not active or the site is set up as a parked domain. When my script hits a my parked site, it still tries to back it up, but there's no directory for it in /var/www, so I get unexpected results. I could put in some logic to make sure there are files in the directory, but I am wondering if there's a way to get a list of only the active, non-parked-domain sites. I'm not skilled enough to understand your code, but I thought maybe there is an easy way. Here's the code:

source /opt/webinoly/lib/sites

# Generate array of sites (using part of List Sites command in webinoly)
     for site in /etc/nginx/sites-available/*
     do
          domi=$(echo $site | cut -f 5 -d "/")
          [[ -a /var/www/$domi ]] && sign="${gre} -" || sign="${blu} *${gre}"
          [[ $domi != "default" && $domi != $(conf_read tools-port) ]] && SITEL$
     done

#print site list
echo $SECONDS: SITE LIST
for SITE in ${SITELIST[@]}; do
echo $SECONDS: $SITE
done
by Rookie
I decided to add a simple check in my script -- if there is no /var/www/htdocs folder for any site, then skip.
by Expert

Try something like this:

for site in "/var/www"/*
 do
   domi=$(echo $site | cut -f 4 -d "/")
   echo $domi
 done

This code should list only sites with data-folder in raw format (without colors and hyphens).

by Rookie
Thanks! I'll give that a try.

1 Answer

0 votes
by Expert
Sounds good!

Actually, now the list command have a very similar approach for sites with "non-data folder" for example parked domains and reverse proxy sites are marked with a blue asterik instead of a hyphen.

Definitely we can do something similar for sites that exist but they are in turned off status.
by Rookie
edited by

Cool! Speaking of parked domains, can you please tell me how to add a secondary domain for a website that would forward to the primary domain? I have two domains pointed to the server, primarydomain.com and secondarydomain.com. I have one site, primarydomain.com. I would like traffic to secondarydomain.com to cause primarydomain.com to load.

Thanks

EDIT: I read about and tried the -parked option. Two issues happened:

  1. It works, but the URL doesn't change to primarydomain.com, and ssl doesn't work (but it is fixed if any link is clicked). Is there a way to cause the domain to change to primarydomain.com?
  2. I got an error after I typed in the domain name during the -parked command:
# site secondarydomain.com -parked

Site secondarydomain.com has been successfully created!

Main site domain: primarydomain.com

Parked domain was successfully configured!

Job for nginx.service failed because the control process exited with error code.

See "systemctl status nginx.service" and "journalctl -xe" for details.
by Expert

You don't need a server to redirect a complete domain, most domain registrars include this feature. If you want to use Nginx:

server {
 listen 80;
 listen [::]:80;
 server_name domain.com;
 return 301 $scheme://example.com$request_uri;
}

When you see an Nginx error, you can use nginx -t to debug it and fix it.

by Rookie

I am using Cloudflare, but I learned that they have an option for forwarding the domain. I didn't think they had it but I should have researched it. However, the free plan only allows for three page rules, so the Nginx method might be better from that perspective.

by Rookie
edited by
EDIT: works fine, my own mistake caused it not to work.

No matter what I do, I can't get the redirect to work. I've been fighting with it for hours now. Instead of redirecting, it simply opens the existing site without changing the URL. I've tried editing nginx.conf with the code provided above (before and after the other server blocks), and the domain.com file inside /etc/nginx/sites-available. I have been using nginx -t and no errors are found. I've been clearing my browser cache and using private browser windows. I can't figure out what I am doing wrong. Thanks!!!
by Expert
You should have only one server block for each port and server_name combination, the old server block should be replaced by this one.

Also, remember that nginx must be restarted.
by Rookie
Fixed -- my mistake. It works perfectly.
Welcome to the Community site for Webinoly.

Our Optimized LEMP Web Server is a powerful set of commands for doing just about anything you could wish.

With Webinoly you can set up your NGINX web server in just one step.

* * * * * * *

To report a bug, please create a new issue on GitHub or ask a question here with the bug tag.
Webinoly Support Paypal Donations

PayPal · GitHub Sponsors · Bitcoin

It is very important that any visitor to the site read the disclaimer, terms of use and privacy and legal statement before start browsing.

...