Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- craete_nginx_vhost() {
- # Example call: craete_nginx_vhost example.org 10.10.3.1:80
- [ -z "$1" -o -z "$2" ] && echo 'ERROR: $1 or $2 must be set!' && exit 1
- local vhostname=$1
- local backend=$2
- cat > /etc/nginx/sites-available/${vhostname}.conf <<_EOF_
- server {
- listen 80;
- server_name $vhostname;
- include common.conf;
- client_body_timeout 300;
- client_max_body_size 1500m;
- location / {
- proxy_pass http://$backend;
- proxy_buffering on;
- proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;
- proxy_read_timeout 300;
- ### Set headers ####
- proxy_set_header Host \$host;
- proxy_set_header X-Real-IP \$remote_addr;
- #proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
- ### By default we don't want to redirect it ####
- proxy_redirect off;
- }
- access_log /var/log/nginx/${vhostname}_access.log;
- error_log /var/log/nginx/${vhostname}_error.log;
- }
- _EOF_
- }
- # For example call function:
- craete_nginx_vhost example.org 10.10.3.1:80
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement