How to authorisation resctricted access to public_ip:port/extension url in Ubuntu?

Hello,
I am dealing with live video streaming server and have no problem with video quality. The main issue is that I am unable to restrict access to related address.

Apache2 is installed into system.

My objective is to make it "authorisation restricted access". There should be a username : password database and when somebody tries to login through that port nr, url query will be carried out and user wiill be accepted when user : pass
are matches.

Stream link is in below format:

http://public_ip:port/test

What I need to do is to convert it into this one:

http://user:password@public_ip:port/test

or

http://public_ip:port/test?u=user:p=password

I read many different topics but I could not find the answer of my question; from where I should start up to proceed. Do you think that apache mod_proxy or nginx would be a solution for this? Or is there a much simpler way to achieve my aim?

PS: .htaccess and .htpasswd files are not solution for this case because port nr is not "80"

thanks in advance
Boris

Checkout <Directory> block in the main Apache configuration,

Configuration will be something like this

<VirtualHost *:8080>
...
...
# Private access
<Directory /var/www/yoursite/userdirectory>
    AuthUserFile /path/to/.htpasswd
    AuthName "Some Name"
    AuthType Basic
    require user <username>
    deny from all
    allow from <allowed ip>
</Directory>

# Public access
<Directory /var/www/yoursite/public>
    Satisfy any
</Directory>
...
...
</VirtualHost>

Hello,
Thanks for your reply but port nr cant be 8080 or 80. For example, assume that I will forward my stream to port 14001.

http://111.222.11.22:14001/test_movie

At client side, user should enter above url in this format:

http://user:pass@111.222.11.22:14001/test_movie

( I incidentally left space between : and p . When there is no space, smile-face comes out)

In my case .htpasswd and .htaccess files are not working for access authorisation. User will connect to server through VLC player by typing that url and each user will have different username and different password.
If you have an idea about how it can be done, I would like to get your thought. As I am not certain on which field i should try to work/learn details, your thought would be helpful.
Some persons says "cgi-bin" do this task, some others say "no, the best solution is apache mod_proxy" and some says "you should create an html file in your web directory and you should compile your binary file and connect your html to your binary file" but i do not know which one is the right answer. Maybe the fourth answer would make my task much more easier.

Thanks in advance
Boris

Thanks. This is very useful post authorisation resctricted access to

public_ip:port/extension 

url in Ubuntu. It is just awesome.