-
Notifications
You must be signed in to change notification settings - Fork 1k
Common NGINX RTMP Live Server Installation Error and How to Resolve It
There are several common errors that occur during the installation and configuration of the NGINX live server, particularly involving SSL, the on_publish parameter, and incorrect server start/stop commands. This guide will help you identify and resolve these issues to ensure your live streaming server functions correctly.
- Your NGINX live server redirects all traffic from HTTP to HTTPS.
- Live streaming functions are not working correctly.
- The stats image displays incorrectly, indicating a misconfiguration.
Incorrect Stats Image:

Correct Stats Image:

- Issue: The NGINX server is configured to redirect all HTTP traffic to HTTPS. This is a common misconfiguration.
- Resolution: The NGINX RTMP server must be configured to work with both HTTP and HTTPS. Ensure that your NGINX configuration allows for both protocols without forced redirection.
-
Issue: The
on_publishparameter and otheron_*parameters in thenginx.conffile are set to use HTTPS. -
Resolution: All
on_*parameters in thenginx.confmust use HTTP, not HTTPS. They must not redirect to HTTPS.
-
Issue: A very common error is attempting to start NGINX using the following command:
/etc/init.d/nginx start
This does not work because NGINX in this setup is a compiled version, not the default system version.
-
Resolution: Use the correct start/stop commands for the compiled NGINX version:
-
Stop NGINX:
sudo /usr/local/nginx/sbin/nginx -s stop
-
Start NGINX:
sudo /usr/local/nginx/sbin/nginx
-
-
Edit NGINX Configuration:
- Open your
nginx.conffile in a text editor. - Locate the sections where
on_publishand otheron_*parameters are defined.
application live { live on; on_publish http://localhost/AVideo/plugin/Live/on_publish.php; # Other on_* parameters }
- Open your
-
Ensure HTTP Usage:
- Make sure all
on_*parameters use HTTP.
on_publish http://localhost/AVideo/plugin/Live/on_publish.php;
- Make sure all
-
Prevent HTTP to HTTPS Redirection:
- Ensure your server blocks for RTMP and HTTP do not force redirect HTTP traffic to HTTPS.
server { listen 80; server_name your-server.com; location / { # No redirection to HTTPS here } }
-
Restart NGINX:
- After making these changes, restart the NGINX server to apply the new configuration.
sudo /usr/local/nginx/sbin/nginx -s stop && sudo /usr/local/nginx/sbin/nginx
If you access the URL http://localhost/AVideo/plugin/Live/on_publish.php (which could also be your IP address or domain name, depending on your on_publish parameter) directly in your browser, an HTTP error code 401 is expected. This means you did not send the correct credentials. Your RTMP publisher, like OBS, will send the correct credentials to NGINX, which will then forward them to the on_publish script.
-
If the credentials are correct, it will return HTTP code 200, allowing the connection.
-
If your
on_publishis correctly configured, when you use the RTMP publisher, you will see some lines in your AVideo logs with the string:AVideoLog::DEBUG: NGINX ON Publish
To ensure your configuration is correct and the on_publish script is working properly, follow these steps:
-
Configure OBS:
- Open OBS.
- Go to
Settings->Stream. - Set the
ServicetoCustom. - Set the
Serverto your RTMP URL (e.g.,rtmp://your-server.com/live). - Set the
Stream Keyto your desired stream key.
-
Start Streaming:
- Click
Start Streamingin OBS.
- Click
-
Check AVideo Logs:
- Open a terminal on your server.
- Use the following command to monitor the AVideo logs in real-time and filter for
NGINX ON Publishentries:
tail -f /var/www/html/AVideo/videos/avideo.log | grep -i "NGINX ON Publish"
-
Verify Log Entries:
- If your
on_publishis correctly configured and the credentials are correct, you should see log entries like:
AVideoLog::DEBUG: NGINX ON Publish ... - If your
-
Troubleshoot if Necessary:
- If you do not see any
NGINX ON Publishentries in the logs, it means theon_publishrequest has never reached your server. Double-check your NGINX and OBS configurations.
- If you do not see any