Skip to content

Increment backend port also when commented#1791

Merged
serghey-rodin merged 1 commit intooutroll:masterfrom
henri-hulski:backend_port
Oct 28, 2021
Merged

Increment backend port also when commented#1791
serghey-rodin merged 1 commit intooutroll:masterfrom
henri-hulski:backend_port

Conversation

@henri-hulski
Copy link
Contributor

This allows to grep the incremented port also for other backends then php-fpm with %backend_lsnr% in the web template.

This allows to grep the incremented port also for other backends then php-fpm with `%backend_lsnr%` in the web template.
@henri-hulski
Copy link
Contributor Author

henri-hulski commented Dec 18, 2018

This is an example how I use it in a wsgi app with gunicorn. It works out of the box with this patch applied.

Backend template:

;[%backend%]
;listen = 127.0.0.1:%backend_port%

;user = %user%
;group = %user%

;listen.owner = %user%
;listen.group = www-data

;pm = ondemand
;pm.max_children = 4
;pm.max_requests = 4000
;pm.process_idle_timeout = 10s
;pm.status_path = /status

;env[HOSTNAME] = $HOSTNAME
;env[PATH] = /usr/local/bin:/usr/bin:/bin
;env[TMP] = /home/%user%/tmp
;env[TMPDIR] = /home/%user%/tmp
;env[TEMP] = /home/%user%/tmp

Nginx web template (*.stpl):

server {
    listen      %ip%:%web_ssl_port% ssl http2;
    server_name %domain_idn% %alias_idn%;
    access_log  /var/log/nginx/domains/%domain%.log combined;
    access_log  /var/log/nginx/domains/%domain%.bytes bytes;
    error_log   /var/log/nginx/domains/%domain%.error.log error;

    ssl_certificate      %ssl_pem%;
    ssl_certificate_key  %ssl_key%;

    client_max_body_size 10M;
    keepalive_timeout    15;

    location / {
        proxy_pass          http://%backend_lsnr%/;
        proxy_redirect      off;
        proxy_set_header    Host                    $host;
        proxy_set_header    X-Real-IP               $remote_addr;
        proxy_set_header    X-Forwarded-For         $proxy_add_x_forwarded_for;
        proxy_set_header    X-Forwarded-Protocol    $scheme;

        # Define the maximum file size on file uploads
        client_max_body_size 5M;
    }

    location ~ /\.git/  {return 404;}

    error_page  403 /error/404.html;
    error_page  404 /error/404.html;
    error_page  500 502 503 504 /error/50x.html;

    location /error/ {
        alias   %home%/%user%/web/%domain%/document_errors/;
    }

    location ~* "/\.(htaccess|htpasswd)$" {
        deny    all;
        return  404;
    }

    location /vstats/ {
        alias   %home%/%user%/web/%domain%/stats/;
        include %home%/%user%/conf/web/%domain%.auth*;
    }

    include     /etc/nginx/conf.d/phpmyadmin.inc*;
    include     /etc/nginx/conf.d/phppgadmin.inc*;
    include     /etc/nginx/conf.d/webmail.inc*;

    include     %home%/%user%/conf/web/snginx.%domain%.conf*;
}

@serghey-rodin
Copy link
Collaborator

Thanks @henri-hulski

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants