Failing to connect to local nginx server

I tried following these two tutorials, with the intent of hosting an HTTP server, and then ultimately an rtmp server, on my Ubuntu 23.04 machine.


https://ubuntu.com/tutorials/install-and-configure-nginx#2-installing-nginx

https://obsproject.com/forum/resources/how-to-set-up-your-own-private-rtmp-server-using-nginx.50

 

 

I learned a couple things.

 

First, I tried to access the http server which is hosted port 80 with the default configuration.


On both Firefox and Chrome, I found if you simply try to access:

http://localhost:80

your web browser will try to access the URL with https instead of http. To avoid this, enter your local IP:

http://127.0.0.1:80


Now, you should be able to access the default webpage confirming the server is up and running.



If you want to host the server on a different port, open this file with sudo:

/etc/nginx/sites-enabled/default

 


Scroll down and you'll find this section:


server {
        listen 80 default_server;
        listen [::]:80 default_server;



Follow that pattern to add lines to listen to the ports, and feel free to remove those existing lines.


For example:


server {
        listen 7483 default_server;
        listen [::]:7483 default_server;
        listen 7484 default_server;
        listen [::]:7484 default_server;


I am now allowing serving for ports 7483 and 7484.



Now update this file with sudo:

/usr/local/nginx/conf/nginx.conf



And for each server, update this section with the correct port:



    server {
        listen       7483;




Then restart nginx:


sudo service nginx restart






EDIT:

I could not get rtmp to work and I was so confused. I uninstalled nginx completed, followed this, and it worked:

https://formatswap.com/blog/linux-tutorials/how-to-install-an-nginx-rtmp-server-in-ubuntu-22-04/





Comments