Nginx is a web server that handles requests from clients and serves the web pages or files. RunCloud provides its own Nginx package that is different from the default one in Ubuntu. Therefore, the Nginx package name is changed to nginx-rc
to avoid conflict with the Ubuntu repository.
Basic Command
You don’t have to run any of these commands if you are managing your server through the RunCloud Panel. However, if you want to manually control the Nginx service, you can use these commands in the terminal.
For example:
If you want to start the Nginx service, you can use:
systemctl start nginx-rc
This will start the Nginx service and make it ready to serve the web applications.
If you want to stop the Nginx service, you can use:
systemctl stop nginx-rc
This will stop the Nginx service and make it unavailable to serve the web applications.
If you want to test the Nginx configuration for syntax errors, you can use:
nginx-rc -t
This will check the Nginx configuration files and report any errors or warnings. This is useful before you reload or restart the Nginx service to make sure that the configuration is valid.
If you want to reload the Nginx service, you can use:
systemctl reload nginx-rc
This will reload the Nginx configuration without stopping the service. This is useful when you make changes to the Nginx configuration and need to apply them without interrupting the service.
If you want to restart the Nginx service, you can use:
systemctl restart nginx-rc
This will stop and start the Nginx service again. This is useful when you want to clear the cache or fix some errors.
If you want to enable the Nginx service to start automatically after reboot, you can use:
systemctl enable nginx-rc
This will create a symbolic link that tells the system to start the Nginx service when the system boots up.
If you want to disable the Nginx service from starting automatically after reboot, you can use:
systemctl disable nginx-rc
This will remove the symbolic link that tells the system to start the Nginx service when the system boots up.
Nginx Location
Nginx is installed and configured in different locations from the default ones in Ubuntu. You can find the Nginx installation and configuration files in the following locations:
- Installation location:
/RunCloud/Packages/nginx-rc
- Main configuration file:
/etc/nginx-rc/nginx.conf
Web Application Config
Each web application has its own Nginx configuration file that defines the server settings, such as the server name, root directory, error log, access log, etc. You can find the web application configuration file in the following location: /etc/nginx-rc/conf.d/[app name].conf
For example, if your web application name is myapp, the configuration file will be located inside /etc/nginx-rc/conf.d/myapp.conf
Do not change this config manually since it will be overwritten by RunCloud when rebuilding web application config. You can manage your web application config from the RunCloud panel.
Custom Nginx config
If you want to modify your Nginx config, you can create or edit custom Nginx config files for your web application. You can find the custom Nginx config files in the following location /etc/nginx-rc/extra.d/*.conf
Although you can directly create config files via CLI, we highly recommend you create or edit custom Nginx config files from the Nginx Config menu inside the RunCloud Panel. This will allow you to take advantage of the many pre-defined configuration templates.
For example, if you want to allow your IP address to access the /admin
URL while preventing other people from accessing it, you can create a new config file from the RunCloud dashboard, and paste the configuration below:
location ~ /admin {
allow 192.168.1.0; # This should be replaced with your IP address
deny all; # Deny everyone from accessing this URL
}
If your web application name is runcloud-blog
, you can find the main Nginx config file inside /etc/nginx-rc/conf.d/runcloud-blog.d/main.conf
.
This file contains the basic settings for your web application, such as the server name, root directory, error log, access log, etc. Do not edit this file manually, because it might break the RunCloud system. If you think there is a bug, please create a support ticket.