Skip to content

Instantly share code, notes, and snippets.

@jaapmarcus

jaapmarcus/cp.stpl

Created Aug 5, 2020
Embed
What would you like to do?
Proxy HestiaCP to port 443
#=======================================================================#
# Default Web Domain Template #
# DO NOT MODIFY THIS FILE! CHANGES WILL BE LOST WHEN REBUILDING DOMAINS #
#=======================================================================#
server {
listen %ip%:%proxy_ssl_port% ssl http2;
server_name %domain_idn% %alias_idn%;
ssl_certificate %ssl_pem%;
ssl_certificate_key %ssl_key%;
ssl_stapling on;
ssl_stapling_verify on;
error_log /var/log/%web_system%/domains/%domain%.error.log error;
include %home%/%user%/conf/web/%domain%/nginx.hsts.conf*;
location / {
proxy_pass https://%ip%:8083;
}
location /error/ {
alias %home%/%user%/web/%domain%/document_errors/;
}
location @fallback {
proxy_pass https://%ip%:%web_ssl_port%;
}
location ~ /\.ht {return 404;}
location ~ /\.svn/ {return 404;}
location ~ /\.git/ {return 404;}
location ~ /\.hg/ {return 404;}
location ~ /\.bzr/ {return 404;}
include %home%/%user%/conf/web/%domain%/nginx.ssl.conf_*;
}
#=======================================================================#
# Default Web Domain Template #
# DO NOT MODIFY THIS FILE! CHANGES WILL BE LOST WHEN REBUILDING DOMAINS #
#=======================================================================#
server {
listen %ip%:%proxy_port%;
server_name %domain_idn% %alias_idn%;
include %home%/%user%/conf/web/%domain%/nginx.forcessl.conf*;
location / {
return 301 https://%domain_idn%/;
}
location /error/ {
alias %home%/%user%/web/%domain%/document_errors/;
}
location @fallback {
proxy_pass http://%ip%:%web_port%;
}
location ~ /\.ht {return 404;}
location ~ /\.svn/ {return 404;}
location ~ /\.git/ {return 404;}
location ~ /\.hg/ {return 404;}
location ~ /\.bzr/ {return 404;}
include %home%/%user%/conf/web/%domain%/nginx.conf_*;
}
@inputuserhere

This comment has been minimized.

Copy link

@inputuserhere inputuserhere commented Aug 10, 2020

Nice template! But whenever I go to sub.domain.tld/phpmyadmin it gives me an error "We're working on it". I have to remove this template in order to access phpmyadmin.

@jaapmarcus

This comment has been minimized.

Copy link
Owner Author

@jaapmarcus jaapmarcus commented Aug 10, 2020

If you use the same subdomain for phpmhyadmin and control panel it will not work as we send trough al traffic without ay exceptions.

This is only how to fix the issue reverse proxy to your control panel.

https://forum.hestiacp.com/t/hostname-without-port/1444 or any other system / domain
https://forum.hestiacp.com/t/nginx-reverse-proxy-for-docker-app/1427/15

If you need to connect to a http site you can replace the Location / to

location / {
    proxy_pass      http://%ip%:8083;
}

If you need it available on http

Add

location / {
    proxy_pass      http://%ip%:8083;
}

You are also able to replace port / ip with the required ip / port

@inputuserhere

This comment has been minimized.

Copy link

@inputuserhere inputuserhere commented Aug 11, 2020

Its not because of http, because with my domain, not subdomain, I can connect to phpmyadmin via https, but not with my subdomain. I thought the script blocked access using the main domain and only allowed traffic using the subdomain, apparently not. I though this might be a security risk?

@anhhtz

This comment has been minimized.

Copy link

@anhhtz anhhtz commented Feb 20, 2021

Hello,

Are there any ways to use upstream like the block below ?

### quiz
    upstream quiz {
      least_conn;
      server 172.30.0.20:5433;
      server 172.20.0.22:6433 down;
    }

Thanks !

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