coturn / coturn

coturn TURN server project
Other
11.37k stars 2.02k forks source link

Regarding the issue of web admin, error message "To use the HTTPS admin connection, you have to set the database table admin_user with the admin user accounts." #1525

Open Lynxhide opened 4 months ago

Lynxhide commented 4 months ago

configuration information: web-admin web-admin-ip=x.x.x.x web-admin-port=8080 web-admin-listen-on-workers

url:https://x.x.x.x:8080 Google Chrome Access Error Message: TURN Server https admin connection

To use the HTTPS admin connection, you have to set the database table admin_user with the admin user accounts.

dangngoctam00 commented 4 months ago

@Lynxhide , I think you have to connect database and create user with username, password, for example, I could use sqlite and here is the table:

image

To create user, you could refer to this: https://github.com/coturn/coturn/wiki/turnadmin

Lynxhide commented 4 months ago

The version used is docker/4.6.2-r9 Using commands "$ turnadmin -d [-b | -e | -M | -N ] -u " ,Adding an admin user and querying the admin_user table in the mariadb 5.5 database did not find any inserted records. What is the reason?

Output returned by executing command: 0: (806284): INFO: MySQL DB connection success: 0: (806284): INFO: log file opened: /var/log/turn_806284_2024-06-21.log 0: (806284): INFO: Connection is not secure. 0: (806284): INFO: MySQL connection was closed. screenshot-20240621-102636

dangngoctam00 commented 4 months ago

hello @Lynxhide , Could you test with this command, here I'm using redis, if you use mysql, connection string option will be -M.

./bin/turnadmin -P -p <password>
./bin/turnadmin -a -u <username> -r <realm> -p <result_of_above_command> -N "ip=127.0.0.1 dbname=0 password=turnserver port=6379 connect_timeout=60"

Log:

0: (18446744073709551615): INFO: System cpu num is 10
0: (18446744073709551615): INFO: log file opened: /var/tmp/turn_56107_2024-06-21.log
0: (18446744073709551615): INFO: System enable num is 10
0: (18446744073709551615): INFO: Redis DB sync connection success: ip=127.0.0.1 dbname=0 password=turnserver port=6379 connect_timeout=60
0: (18446744073709551615): INFO: Redis connection was closed.
Lynxhide commented 4 months ago

hello@dangngoctam00 I have configured Redis and MySQL in my configuration file. Is there a conflict? Can only choose between the two?

dangngoctam00 commented 4 months ago

@Lynxhide , I think you could only use one database type at once although I've not tested it. But the tool turnadmin seems use the connection passed to it when running.

Lynxhide commented 4 months ago

Executed the above command ./bin/turnadmin -P -p /usr/local/coturn/bin/turnadmin -a -u admin -r xxx-p xxx -M "host=localhost dbname=coturn user=turn password=turn"

Message output 0: (808362): INFO: MySQL DB connection success: 0: (808362): INFO: log file opened: /var/log/turn_808362_2024-06-21.log 0: (808362): INFO: Connection is not secure. 0: (808362): INFO: MySQL connection was closed.

conclusion:I still couldn't find any record information when searching in mariadb

dangngoctam00 commented 4 months ago

Could you check connection string: 0: (808362): INFO: Connection is not secure., I didn't see successful log. From this docs: https://github.com/coturn/coturn/blob/master/docs/MySQL.md

If you have to use a secure MySQL connection (SSL) then you have to use also the optional connection string parameters for the secure communications: ca, capath, cert, key, cipher (see http://dev.mysql.com/doc/refman/5.1/en/ssl-options.html for the command options description).

Lynxhide commented 4 months ago

Using a database account and password may allow normal connection to mariadb

Using Redis, the turnadmin command can create admin account information and query key values in db 0, but web admin still cannot be used /usr/local/coturn/bin/turnadmin -P -p xxx $5$80bf07085535f6a4$94b6a0d2f52a87e0118e8af38542d3ca226f087c6595bba99add534c70747f51 /usr/local/coturn/bin/turnadmin -a -u admin -r xx -p xx--redis-userdb="ip=xxxx dbname=0 password=xxx port=6379 connect_timeout=30"

Message output: 0: (808778): INFO: Redis DB sync connection success: ip=x.x.x.x dbname=0 password=xxxx port=6379 connect_timeout=30 0: (808778): INFO: log file opened: /var/log/turn_808778_2024-06-21.log 0: (808778): INFO: Redis connection was closed.

Connect Redis to query the keys value as follows: xxxx:6379> keys * 1) "turn/realm/realmtest/user/admin/key" xxxx:6379> GET "turn/realm/realmtest/user/admin/key" "9efdfc069114229163e01a6030271cf8"

Web error information: To use the HTTPS admin connection, you have to set the database table admin_user with the admin user accounts.

dangngoctam00 commented 4 months ago

@Lynxhide sorry, but it seems like we have to use both mysql and redis, so my previous thought is not correct. I've tested web admin with sqlite several months ago, could you test it? config of coTURN:

userdb=/Users/ngtam/Projects/coturn/turndb
redis-userdb="ip=127.0.0.1 dbname=0 password=turnserver port=6379 connect_timeout=60"

If you cannot insert admin account by turnadmin tool, I suggest you should do it manually after generating encrypted password.

Lynxhide commented 4 months ago

@dangngoctam00 Currently, I have tried using commands from MySQL and Redis to add an admin account for HTTPS access, but the browser still reported the same error. Can you access web admin using sqlite? My operation is also based on the document.

Redis is necessary for us to use and is also used to store verification information.

dangngoctam00 commented 4 months ago

@Lynxhide I've just tested, I cannot use userdb and redis-userdb at once, sorry for my confusion. What verification information do you need to store?

image
Lynxhide commented 4 months ago

@dangngoctam00 Is it convenient to post your configuration file? We have only connected to Redis, but it has not been put into use yet. I want to use the web admin function now.

May I ask if the information viewed by the web admin is similar to the information output by the prometheus client-c monitoring tool?

dangngoctam00 commented 4 months ago

Here is my example configuration:

listening-port=3478
tls-listening-port=5349
listening-ip=0.0.0.0
listening-ip=127.0.0.1
relay-ip=127.0.0.1
min-port=1000
max-port=30200
verbose
fingerprint
prometheus
use-auth-secret
static-auth-secret=authkey
userdb=/Users/ngtam/Projects/coturn/coturn/turndb/turndb
redis-statsdb="ip=127.0.0.1 dbname=1 password=turnserver port=6379 connect_timeout=5"
realm=127.0.0.1
max-bps=0
bps-capacity=0
log-file=/Users/ngtam/Projects/coturn/coturn/logs/
allow-loopback-peers
no-multicast-peers
mobility
no-cli
cli-password=qwerty
web-admin
web-admin-port=8999

The information provided by web admin seems instantly compared to prometheus, the traffic in prometheus is only updated at the end of session,... But when I used web admin, I see the coTURN service crash without reason, IMHO, I think it's not necessary to use web-admin. If you want to collect traffic instantly, you could use redis pub-sub to analyze data.

Lynxhide commented 4 months ago

@dangngoctam00 May I ask you how Redis pub sub can analyze real-time traffic? Do you need to use other tools?

What is the difference between the parameters use-auth-secre, static-auth-secret=authkey and lt-cred-mech?

dangngoctam00 commented 4 months ago
  1. Redis pubsub message has username and allocation ID and traffic information, so basically you could implement a new service to process these service and analyze data, reference: https://github.com/coturn/coturn/blob/master/turndb/schema.stats.redis
  2. use auth secret is used when you need dynamic user and time-based token, it uses static auth secret to verify username, password by verifying signature, you could search for keyword 'turn api service', reference: https://stackoverflow.com/questions/35766382/coturn-how-to-use-turn-rest-api
Lynxhide commented 4 months ago

@dangngoctam00 Do you have any suggestions for monitoring COTURN? I am currently using Prometheus. Do you have a document explaining the indicator information?

At present, we have not found the reason why web admin cannot be accessed. There may still be some areas that have not been properly configured. What is the available version of coturn for your testing?

dangngoctam00 commented 4 months ago

@Lynxhide

  1. I'm still finding out a way to monitor it because prometheus is not good as expected. Like I said above, processing pubsub message may be a good way. If you have any idea, we could discuss it.
  2. For document, I have not found an official about it, just follow the result of prometheus and some discussion on this repository.
  3. I'm using version 4.6.2.
Lynxhide commented 4 months ago

@dangngoctam00 For COTURN monitoring, currently Prometheus only supports session count related indicator information, and there is no documentation or other reference. The explanation of the indicators is not clear enough. Does Prometheus currently support obtaining data information through API interfaces? Because no similar documents were found on GitHub.

The version I am currently using is: https://github.com/coturn/coturn/releases/tag/docker%2F4.6.2 -r9

hudson-s commented 3 months ago

@Lynxhide 我刚刚测试过,我不能使用 userdbredis-userdb 立刻,为我的困惑感到抱歉。您需要存储哪些验证信息? 图像

How do I open this web page?