M
M
MaksSmag2020-11-09 09:30:47
Nginx
MaksSmag, 2020-11-09 09:30:47

Why is '"if" directive is not allowed here in /etc/nginx/sites-enabled/vst-install.sh:15' displayed after installing an SSL certificate?

Followed the installation instructions: create 2 files with keys, with the domain name and extension (.crt, .key). Edited the nginx site config, gives:

Failed to start a High perfomance web server and a reverse proxy server

I look at the nginx logs, writes that there is an error in a file that I have never touched:
"if" directive is not allowed here in /etc/nginx/sites-enabled/vst-install.sh:15

Where to look for the reason - in nginx conf. or in vst-instakk.sh? I'll throw off both files...
Site config:
server {
  listen 443 ssl;
  ssl_certificate /etc/ssl/premsite.ru.crt;
  ssl_certificate_key /etc/ssl/premsite.ru.key;
  root /var/www/sites/projects/Business/public_html;
  set $php_sock unix:/var/run/php/php7.3-fpm.sock;
  index index.html index.htm index.php;

  server_name premsite.ru;

  location / {
    try_files $uri $uri/ =404;
  }
  location ~* ^.+\.(jpg|jpeg|gif|png|ico|tiff|css|js)$ {
    expires 6M;
    add_header Cache-Control public;
  }
  location ~ \.php$ {
        	include snippets/fastcgi-php.conf;
        	fastcgi_pass $php_sock;
        	fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

vst-install.sh:
#!/bin/bash
# Vesta installation wrapper
# http://vestacp.com

#
# Currently Supported Operating Systems:
#
#   RHEL 5, 6, 7
#   CentOS 5, 6, 7
#   Debian 7, 8
#   Ubuntu 12.04 - 18.04
#

# Am I root?
if [ "x$(id -u)" != 'x0' ]; then
    echo 'Error: this script can only be executed by root'
    exit 1
fi

# Check admin user account
if [ ! -z "$(grep ^admin: /etc/passwd)" ] && [ -z "$1" ]; then
    echo "Error: user admin exists"
    echo
    echo 'Please remove admin user before proceeding.'
    echo 'If you want to do it automatically run installer with -f option:'
    echo "Example: bash $0 --force"
    exit 1
fi

# Check admin group
if [ ! -z "$(grep ^admin: /etc/group)" ] && [ -z "$1" ]; then
    echo "Error: group admin exists"
    echo
    echo 'Please remove admin group before proceeding.'
    echo 'If you want to do it automatically run installer with -f option:'
    echo "Example: bash $0 --force"
    exit 1
fi

# Detect OS
case $(head -n1 /etc/issue | cut -f 1 -d ' ') in
    Debian)     type="debian" ;;
    Ubuntu)     type="ubuntu" ;;
    Amazon)     type="amazon" ;;
    *)          type="rhel" ;;
esac

# Check wget
if [ -e '/usr/bin/wget' ]; then
    wget http://vestacp.com/pub/vst-install-$type.sh -O vst-install-$type.sh
    if [ "$?" -eq '0' ]; then
        bash vst-install-$type.sh $*
        exit
    else
        echo "Error: vst-install-$type.sh download failed."
        exit 1
    fi
fi

# Check curl
if [ -e '/usr/bin/curl' ]; then
    curl -O http://vestacp.com/pub/vst-install-$type.sh
    if [ "$?" -eq '0' ]; then
        bash vst-install-$type.sh $*
        exit
    else
        echo "Error: vst-install-$type.sh download failed."
        exit 1
    fi
fi

exit

Everything was fine before SSL.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
smilingcheater, 2020-11-09
@MaksSmag

Why did you put this shell file in the nginx sites config folder?
He tries to connect it as a config file, respectively, expects that the syntax in it is like in the nginx config file, and not in the shell file

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question