SOLVED - -webusers and .htpasswd
Zaggy
NullPointerExceptionThe Netherlands Join Date: 2003-12-10 Member: 24214Forum Moderators, NS2 Playtester, Reinforced - Onos, Subnautica Playtester
<div class="IPBDescription">How does this work?</div>Fix: When using the <a href="http://www.askapache.com/online-tools/htpasswd-generator" target="_blank">.htpasswd generator</a>, use <b>digest </b>as Encryption Algorithm , not md5!
More specifically, where to put the .htpasswd file?
What to fill in at the -webusers parameter? filename? direct path to filename?
If I put it next to Server.exe I will get a login screen but it will keep looping, anywhere else I will get an empty page.
Used the .htpasswd generator from <a href="http://www.askapache.com/online-tools/htpasswd-generator/" target="_blank">http://www.askapache.com/online-tools/htpasswd-generator/</a> as described in Dedicated_Server_Usage.txt
Copied over the line with username <md5sum>
More specifically, where to put the .htpasswd file?
What to fill in at the -webusers parameter? filename? direct path to filename?
If I put it next to Server.exe I will get a login screen but it will keep looping, anywhere else I will get an empty page.
Used the .htpasswd generator from <a href="http://www.askapache.com/online-tools/htpasswd-generator/" target="_blank">http://www.askapache.com/online-tools/htpasswd-generator/</a> as described in Dedicated_Server_Usage.txt
Copied over the line with username <md5sum>
Comments
If you use the -webuser and password switch in the command line, then you cannot use an additional htaccess access.
Either htaccess or commandline parameter, where I'm not sure, which is more secure.
If you use the -webuser and password switch in the command line, then you cannot use an additional htaccess access.
Either htaccess or commandline parameter, where I'm not sure, which is more secure.<!--QuoteEnd--></div><!--QuoteEEnd-->
The htaccess method is more secure since it hashes your password. Using the single-user -webuser and -webpass exposes the password in the commandline so it may not be as secure especially when you have other people accessing your server box.
-webuser [username] Specifies the user name for logging into the web server
-webpassword [password] Specifies the password for logging into the web server
-webusers [file name] Loads username/password data from the specified .htpasswd file<!--c2--></div><!--ec2-->
-webadmin (without any arguments) will enable the web server interface. If you use this without the other commands, you can use the web server without having to enter in any users or passwords (obviously this is not secure but it is useful for initial setup or whatever).
The -webuser and -webpassword are used in case you want to define the users and passwords on the command line. In most cases, you will want to setup a .htpasswd file. You can place the .htpasswd file where ever you want as long as you give the full path to the -webusers command.
Here is the section of the Dedicated_Server_Usage.txt file that explains how everything works:
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->The dedicated server includes a web server which can be used to configure the server.
To use the web admin interface, start the dedicated server wuth the -webadmin command
line option and open http://localhost/index.html in your browser.
If you would like to access the web admin interface from a remote computer, you will
need to set up at least one user. The dedicated server has two ways to configure
users for the web admin. The first is using the -webuser and -webpassword options.
This will setup the login information for a single user that can be entered when your
web browser prompts you for log in information.
If you would like to set up multiple users or do not want the password to be stored
in plaintext, you can specify a .htpasswd file using the -webusers command line option.
A .htpasswd file can be generated using the same tools you would use for configuring
an Apache web server. An online tool is available here:
http://www.askapache.com/online-tools/htpasswd-generator
When using this tool, you will want to set the encryption mode to MD5 and the realm
or popup name to whatever you specify for the -webdomain parameter (or localhost if
you don't specify webdomain).
If you are going to access the web server from an internet address, you will need
to specify the address using the -webdomain command line option. If you have multiple
IP addresses, this can also be used to select which one the web server will be
bound to. You can also run multiple web servers on the same machine on different ports
using -webport.<!--c2--></div><!--ec2-->
If it is NOT working this way, please let us know what the problem is.
The issue that we face varies based on the location of .htpasswd If htpasswd is in the root directory, the login popup does not accept any information (it merely asks for login for all eternity). If htpasswd is in another directory (we have tried the /ns2/web directory and /ns2) a white page appears and nothing happens. We are using newly generated apache-style md5 hashes.
If you need more information, let me know!
Server shortcut:
C:\ns2ds\Server.exe -file "C:\ns2ds\settings.txt"
"settings.txt":
-config_path "c:\ns2ds\config"
-name "testserver"
-webadmin
-webport 81
-webusers "c:\.htpasswd"
-map ns2_tram
-limit 24
-webdomain "ipaddress"
I copied over the username:hash and created the .htpasswd in the C:\ directory.
The message I get when I try to access the page:
Access to the webpage was denied
You are not authorized to access the webpage at <a href="http://ipaddress:81/index.html" target="_blank">http://ipaddress:81/index.html</a>. You may need to sign in.
HTTP Error 403 (Forbidden): The server refused to fulfill the request.
If I place the .htpasswd in the server install directory, "C:\NS2DS", I will get the .htpasswd login prompt but it won't take my username or password that I specified.
Thanks for the reply Murphy!
<!--quoteo(post=2013336:date=Nov 7 2012, 12:40 AM:name=Silent262)--><div class='quotetop'>QUOTE (Silent262 @ Nov 7 2012, 12:40 AM) <a href="index.php?act=findpost&pid=2013336"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->Murphy, I am fairly certain that both Zaggy and I have followed the directions in the dedicated_server_usage.txt.
The issue that we face varies based on the location of .htpasswd If htpasswd is in the root directory, the login popup does not accept any information (it merely asks for login for all eternity). If htpasswd is in another directory (we have tried the /ns2/web directory and /ns2) a white page appears and nothing happens. We are using newly generated apache-style md5 hashes.
If you need more information, let me know!<!--QuoteEnd--></div><!--QuoteEEnd-->
What he said, the location appears to determine whether we get a login screen or not.
For .htpasswd:
If not placed next to the Server.exe file, browsing to the webpage will render a blank page.
If you do place it next to the Server.exe file, a login screen will pop up but it will keep popping up, regardless of login info used.
My startup script:
DISPLAY=:1 screen -A -m -d -S ns2 wine Server.exe -name "NL :: 228 :: zaggynl's test server" -webadmin -webdomain 141.138.149.70 -webusers "/home/<username>/ns2server/ns2/.htpasswd" -webport <port> -map ns2_docking -ip 141.138.149.70 -port 27015 -limit 16
.htpassword locations tried:
/home/<username>/ns2server/.htpasswd (blank page)
/home/<username>/ns2server/ns2/.htpasswd (returning login screen)
Working startup script:
DISPLAY=:1 screen -A -m -d -S ns2 wine Server.exe -name "NL :: 228 :: zaggynl's test server" -webadmin -webdomain 141.138.149.70 -webuser admin -webpassword <password> -webport <port> -map ns2_docking -ip 141.138.149.70 -port 27015 -limit 16
Note: /home/<username>/ns2server/ns2/.htpasswd should NOT be present or there will be a re-occurring login prompt.
[USER]:[MD5HASHPASS]:[REALM as in -webdomain]
Then u can place the htpasswd where u want. But the problem with no user is able to access will still be. As it is on my Server. I cant get access due to htpasswd
The problem where the site doesn't render I am not sure about but assuming you use the full path to the .htpasswd file, it will load it correctly. So it really shouldn't matter where you put that file assuming you use the full, non-relative path. The relative path will work if it is relative to the working directory.
The problem where the site doesn't render I am not sure about but assuming you use the full path to the .htpasswd file, it will load it correctly. So it really shouldn't matter where you put that file assuming you use the full, non-relative path. The relative path will work if it is relative to the working directory.<!--QuoteEnd--></div><!--QuoteEEnd-->
<!--quoteo(post=2015891:date=Nov 8 2012, 10:49 PM:name=Max)--><div class='quotetop'>QUOTE (Max @ Nov 8 2012, 10:49 PM) <a href="index.php?act=findpost&pid=2015891"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->Apologizes for the confusion, but there is an error in the documentation. When using the Apache tool, you should select "digest" rather than "MD5". I'm adding in some error messages for the next patch to make this type of problem more obvious.<!--QuoteEnd--></div><!--QuoteEEnd-->
Thank you!