Skip to content

ngrogg/nginx-vhost-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Nginx Vhost Generator

Overview

BASH script for generating an Nginx Vhost. Designed for DEB and RPM servers. Sibling project to Apache Vhost Generator.

Usage

  • help/help, Display help message and exit.

  • generate/Generate, generate Apache Vhost.
    Script is guided, saves to locally generated output folder.
    To bypass guide and generate vhost the following questions are asked :

    • What is the domain?, Ex. rustyspoon.com
      Enter a string.
    • Is there a WWW redirect?, Ex. www.rustyspoon.com
      If there isn't any kind of CNAME redirect this is likely to be no.
      Enter "1" for yes, or "0" for no.
    • Should HTTP traffic redirect to HTTPS?.
      In most cases this will be port 80 traffic to port 443.
      There may be cases where this action is not desired.
      Enter "1" for yes, or "0" for no.
    • Is there a Docroot?
      If the VirtualHost is on a server where the site files are, a Docroot should be defined.
      This configures a generic DocRoot that should be reviewed after Vhost is created.
      While there may be exceptions, this option should not be used with the "Proxy Pass" option following.
      Enter "1" for yes, or "0" for no.
    • Is there a Proxy Pass?
      If the VirtualHost is being configured to proxy traffic to another server, a Proxy Pass should be defined.
      While there may be exceptions, this option should not be used with the preceeding "Docroot" option.
      Enter "1" for yes, or "0" for no.

      Usage. ./nginxVhostGenerator.sh DOMAIN WWW_REDIRECT? HTTP_TO_HTTPS? DOCROOT? PROXY_PASS?
      Ex. ./nginxVhostGenerator.sh rustyspoon.com 1 1 1 0

    IMPORTANT: Vhost will need reviewed before used as some values are generic! See next section for details.

Review

Once the VirtualHost is generated at least the following items should be reviewed before the VirtualHost is used:

  • SSL Certifications, script will put placeholder SSL filepaths in place.
    These should be updated before the VirtualHost is used.
  • SSL Protocols, script will put a few SSL Protocols in place.
    These are probably fine but may not cover all use cases.
  • SSL Ciphers, script will put a few SSL Ciphers in place.
    These will probably need expanded to be used safely in a Production environment.
  • ProxyPass, if ProxyPass option is used a placeholder variable is put in place.
    Use sed or whatever find and replace tool is preferred to replace the placeholder SERVER_IP with the actual server's IP.
  • Docroot, if Docroot option is used a placeholder docroot based on the domain is added.
    Adjust to whatever preferred docroot is used.
  • File Security changes, these are simple placeholders and cover a few encountered examples.
    These may need adjusted and should be reviewed before deployment.

About

Boilerplate BASH script for generating an Nginx Vhost.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages