Add proxy in front

This commit is contained in:
Erik Gustafson
2022-01-04 23:25:26 +01:00
parent 27c8961fef
commit 29f6e0fbd9
7 changed files with 187 additions and 105 deletions

11
templates/proxy.conf.j2 Normal file
View File

@ -0,0 +1,11 @@
server {
server_name {{website.external_hostname}};
location / {
proxy_pass http://{{jails.webserver.ip}}:{{website.port}};
proxy_set_header Host $host:$server_port;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}

View File

@ -79,6 +79,22 @@ $table_prefix = 'wp_';
*/
define( 'WP_DEBUG', false );
if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') {
$_SERVER['HTTPS']='on';
$_SERVER['SERVER_PORT']=443;
}
if ( isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
$_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST'];
define('WP_SITEURL', 'https://{{website.external_hostname}}');
define('WP_HOME', 'https://{{website.external_hostname}}');
}else{
define('WP_SITEURL', "http://{$_SERVER['HTTP_HOST']}");
define('WP_HOME', "http://{$_SERVER['HTTP_HOST']}");
}
/* That's all, stop editing! Happy publishing. */
/** Absolute path to the WordPress directory. */