Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ ENV GIT_REPO=https://github.com/osTicket/osTicket
COPY bin /bin
COPY conf/supervisord /etc/supervisor/conf.d/osticket.conf
COPY conf/msmtp /etc/msmtp.default
COPY conf/default.conf /tmp/default.conf.template

# Conf files
RUN touch /etc/msmtp /etc/osticket.secret.txt /etc/cron.d/osticket && \
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,14 @@ specified in the admin control panel, you need to specify both to the value you'

# Environmental Variables

`HOST`

Sets the 'host' part of the osTicket URL in database, eg. for links in ticket mails.

`ROOT_PATH`

If you want to host osTicket under a subdirectory path of your domain you must set this path here, so osTicket can properly reference it's source files. Defaults to `/`.

`INSTALL_SECRET`

Secret string value for OST installation. A random value is generated on start-up and persisted within the container if this is not provided.
Expand Down
19 changes: 16 additions & 3 deletions bin/osticket-install.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@
'smtp_pass' => getenv("SMTP_PASSWORD"),
'cron_interval' => getenv("CRON_INTERVAL") ?: 5,
'siri' => getenv("INSTALL_SECRET"),
'config' => getenv("INSTALL_CONFIG") ?: INSTALL_CONFIG,
'host' => getenv("HOST"),
'root_path' => getenv("ROOT_PATH"),
'config' => getenv("INSTALL_CONFIG") ?: INSTALL_CONFIG,
);

// Helper functions
Expand All @@ -72,7 +74,7 @@ function convertStrToBool($varName, $default) {
}

// Require files (must be done before any output to avoid session start warnings)
// $_SERVER['HTTP_ACCEPT_LANGUAGE'] = LANGUAGE;
// $_SERVER['HTTP_ACCEPT_LANGUAGE'] = LANGUAGE;
chdir(SETUP_DIR);
require SETUP_DIR.'setup.inc.php';
require SETUP_DIR.'inc/class.installer.php';
Expand Down Expand Up @@ -193,6 +195,10 @@ function convertStrToBool($varName, $default) {
$configFile= str_replace('%CONFIG-DBPASS',$vars['dbpass'],$configFile);
$configFile= str_replace('%CONFIG-PREFIX',$vars['prefix'],$configFile);
$configFile= str_replace('%CONFIG-SIRI',$vars['siri'],$configFile);
if($vars['root_path']){
$configFile = str_replace("# define('ROOT_PATH', '/support/');","define('ROOT_PATH', '".$vars['root_path']."');",$configFile);
}

if (!file_put_contents($installer->getConfigFile(), $configFile)) {
err("Failed to write configuration file");
}
Expand All @@ -219,5 +225,12 @@ function convertStrToBool($varName, $default) {
echo "System Language Set\n";
}

// Install finished
// Update helpdesk_url
echo "Setting helpdesk url to ".$vars['host']."\n";
$sql = "UPDATE `".$vars['prefix']."config` SET `value`='".$vars['host'].$vars['root_path']."' WHERE `key`='helpdesk_url'";
if (db_query($sql, false)) {
echo "helpdesk url Set\n";
}

// Install finished
echo "Install Script finished!\n";
7 changes: 7 additions & 0 deletions bin/update
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ echo $$ > $LOCK_FILE
# Fix
fix

cp /tmp/default.conf.template /etc/nginx/conf.d/default.conf
# configure nginx for possible ROOT_PATH
if [ ! -z $ROOT_PATH ] && [ "$ROOT_PATH" != '/' ]; then
nginx_rewrite="location ^~ $ROOT_PATH { rewrite ^$ROOT_PATH(.*)\$ /\$1 last;}"
sed -i "s|# %APPEND_REDIRECT_HERE%|$nginx_rewrite|g" /etc/nginx/conf.d/default.conf
fi

# Go to src
cd /var/www/src

Expand Down
78 changes: 78 additions & 0 deletions conf/default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Default Server
server {
# Port that the web server will listen on.
listen 80 default;

# Host that will serve this project.
server_name _;

# The location of our projects public directory.
root /var/www/src/public;

# Index
index index.php index.html;

# %APPEND_REDIRECT_HERE%

try_files $uri $uri/ /index.php?$query_string;

set $path_info2 "";

location ~ /include {
deny all;
return 403;
}

if ($request_uri ~ "^/api(/[^\?]+)") {
set $path_info2 $1;
}

location ~ ^/api/(?:tickets|tasks).*$ {
try_files $uri $uri/ /api/http.php?$query_string;
}

if ($request_uri ~ "^/scp/.*\.php(/[^\?]+)") {
set $path_info2 $1;
}

if ($request_uri ~ "^/.*\.php(/[^\?]+)") {
set $path_info2 $1;
}

location ~ ^/scp/ajax.php/.*$ {
try_files $uri $uri/ /scp/ajax.php?$query_string;
}

location ~ ^/ajax.php/.*$ {
try_files $uri $uri/ /ajax.php?$query_string;
}

location / {
try_files $uri $uri/ index.php;
}

location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_param PATH_INFO $path_info2;
fastcgi_param HTTPS $fe_https;
fastcgi_pass unix:/run/php/php-fpm.sock;
}

location ~ /\.ht {deny all;}
}

# Status server
server {
listen 8080;

location /nginx_status {
stub_status on;
access_log off;
}

location ~ ^/(status|ping)$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/run/php/php-fpm.sock;
}
}
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ services:

- LANGUAGE=fa

- HOST=localhost:80
- ROOT_PATH=/
links:
- mysql:mysql
ports:
Expand Down