Difference between revisions of "Configure the TCAdmin website to run with Nginx"

Line 124: Line 124:
 
Logging is commented out in the above configuration. You can enable it by changing #access_log to access_log and reloading the nginx service. That will create a single log file that can get huge after a few days. You can configure log rotation with these instructions: http://www.nginxtips.com/how-to-rotate-nginx-logs/
 
Logging is commented out in the above configuration. You can enable it by changing #access_log to access_log and reloading the nginx service. That will create a single log file that can get huge after a few days. You can configure log rotation with these instructions: http://www.nginxtips.com/how-to-rotate-nginx-logs/
  
== Advanced Configuration ==
+
== Advanced Configuration (optional) ==
 
=== Configuring multiple fastcgi server processes ===
 
=== Configuring multiple fastcgi server processes ===
 
A control panel website with many users connected simultaneously may require additional fastcgi processes to handle the load. You can specify the number of processes in /home/tcadmin/Monitor/tcadmin-config. Change this line:
 
A control panel website with many users connected simultaneously may require additional fastcgi processes to handle the load. You can specify the number of processes in /home/tcadmin/Monitor/tcadmin-config. Change this line:

Revision as of 10:41, 10 October 2015

Install Nginx

Follow these instructions to install the latest version of Nginx: http://wiki.nginx.org/Install


Configure TCAdmin to Execute the Fastcgi Server

Edit the file /home/tcadmin/Monitor/tcadmin-config. Change this line:

ENABLE_FASTCGI_SERVER="False"

to:

ENABLE_FASTCGI_SERVER="True"

If the line doesn't exist add it at the end.

Then restart the monitor service:

/home/tcadmin/Monitor/monitor-service restart


Configure Nginx

Edit the file /etc/nginx/nginx.conf and change:

user nginx;

to:

user tcadmin;

Then execute these commands:

chown --recursive tcadmin:tcadmin /var/lib/nginx
service nginx restart

Configure the control panel website

Create the file /etc/nginx/conf.d/default.conf with the following content. If it already exists rename the existing file to default.conf.old.

upstream tcadmin-fcgi {
        ip_hash;
        server unix:/home/tcadmin/Temp/fastcgi-socket-1;
}

server {
        listen   8880;
        #access_log   /home/tcadmin/Logs/nginx.log;
        root /home/tcadmin/ControlPanel;
        index index.html index.htm default.aspx Default.aspx;

        #Static files are served by nginx
        location ~ \.(css|js|txt|xml|jpg|png|gif|ico)$ {
               gzip            on;
               gzip_min_length 1000;
               gzip_proxied    expired no-cache no-store private auth;
               gzip_types      text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
        }

        #Everything else served by fastcgi server
        location / {
               fastcgi_index Default.aspx;
               fastcgi_pass tcadmin-fcgi;
               include fastcgi_params;
               fastcgi_split_path_info ^(.+\.as[pmh]x)(.*)$;
               fastcgi_param PATH_INFO $fastcgi_path_info;
               fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
               fastcgi_keep_conn off;
               fastcgi_buffering off;
               gzip            off;
               client_max_body_size 100m;
       }
}

After creating the file reload the nginx settings:

service nginx reload

Configure the website to allow secure connections

Create a self signed certificate

The default certificate and private key used by TCAdmin are not compatible with nginx. You must create new ones. Execute the following commands. When it asks for a passphrase enter a word that you can remember.

cd /home/tcadmin/Monitor
openssl genrsa -des3 -out nginx.key 2048

Execute this command. Enter the passphrase that you used in the first step. You can leave all other values blank.

openssl req -new -key nginx.key -out nginx.csr

Execute this command. Enter the passphrase that you used in the first step.

mv nginx.key nginx.key.org
openssl rsa -in nginx.key.org -out nginx.key

Execute this command to create the certificate file.

openssl x509 -req -days 7300 -in nginx.csr -signkey nginx.key -out nginx.crt

Add the following lines to /etc/nginx/conf.d/default.conf under listen 8880;.

listen   8881 ssl;
ssl_certificate /home/tcadmin/Monitor/nginx.crt;
ssl_certificate_key /home/tcadmin/Monitor/nginx.key;

After updating the file reload the nginx settings:

service nginx reload

Change the default ports

If you change the default ports in /etc/nginx/conf.d/default.conf make sure you update the values of WEB_PORT and SECURE_WEB_PORT in /home/tcadmin/Monitor/tcadmin-config and restart the monitor service:

/home/tcadmin/Monitor/monitor-service restart

Enable logging

Logging is commented out in the above configuration. You can enable it by changing #access_log to access_log and reloading the nginx service. That will create a single log file that can get huge after a few days. You can configure log rotation with these instructions: http://www.nginxtips.com/how-to-rotate-nginx-logs/

Advanced Configuration (optional)

Configuring multiple fastcgi server processes

A control panel website with many users connected simultaneously may require additional fastcgi processes to handle the load. You can specify the number of processes in /home/tcadmin/Monitor/tcadmin-config. Change this line:

FASTCGI_SERVERS="1"

to:

FASTCGI_SERVERS="5"

If the line doesn't exist add it at the end.

To configure the monitor to check the health of these processes edit /home/tcadmin/Monitor/TCAdminMonitor.exe.config. Change this line:

<add key="TCAdmin.CheckWebHealth" value="False" />

to:

<add key="TCAdmin.CheckWebHealth" value="True" />

If the line doesn't exist add it under <appSettings>. Then restart the monitor service.

To configure nginx add the correct number of servers to the "upstream tcadmin-fcgi" section in your /etc/nginx/conf.d/default.conf. For example:

upstream tcadmin-fcgi {
       ip_hash;
       server unix:/home/tcadmin/Temp/fastcgi-socket-1;
       server unix:/home/tcadmin/Temp/fastcgi-socket-2;
       server unix:/home/tcadmin/Temp/fastcgi-socket-3;
       server unix:/home/tcadmin/Temp/fastcgi-socket-4;
       server unix:/home/tcadmin/Temp/fastcgi-socket-5;
}

After updating the file reload the nginx service:

service nginx reload

Common Errors

Object reference error when logging in

This should only happen the first time you log in after changing the web server.

Port already in use

If Nginx says the port is already in use make sure you configured TCAdmin to start the fastcgi server instead of the built in web server and restarted the monitor. Also check if there is a process using port 8880 and kill it:

netstat -tlnp|grep 8880

Website doesn't load

Try starting nginx:

service nginx start
Retrieved from "https://help.tcadmin.com/index.php?title=Configure_the_TCAdmin_website_to_run_with_Nginx&oldid=1288"