http://ip/~username doesn't work

Scolpy

Verified User
Joined
Feb 25, 2009
Messages
137
Hello!

after fresh installation I saw that when I'm going into user files via browser using server IP its doesn't actually work and I'm getting this error:
Forbidden

You don't have permission to access /~username on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Apache/2 Server at 81.218.229.185 Port 80
note that I'm using in mod_ruid2.

Thanks!
 
And what is in the logs? See
/var/log/httpd/homedir.log
/var/log/httpd/error_log

I've got in homedir.log:
597 "GET /~username HTTP/1.1"

And in error_log I've got:
[Wed Dec 22 18:57:51 2010] [crit] [client 79.180.46.161] (13)Permission denied: /home/username/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
[Wed Dec 22 18:57:51 2010] [error] [client 79.180.46.161] File does not exist: /var/www/html/403.shtml
 
Just type:

Code:
touch /home/username/.htaccess
chown username:username /home/username/.htaccess

Replace username with the actual username.

Personally I would love to know why it thinks it needs .htaccess.

I havent been able to figure out why it thinks it needs it there.
 
Just type:

Code:
touch /home/username/.htaccess
chown username:username /home/username/.htaccess

Replace username with the actual username.

Personally I would love to know why it thinks it needs .htaccess.

I havent been able to figure out why it thinks it needs it there.
I did it and I still can't access to the site through the IP.
 
It occurs just when Apache can't open a directory for reading.

While you're using mod_ruid2 you'd better disable it. Or try to re-configure apache's ips.conf in order to make apache to run not from user "admin", but "apache" user. In any case, there can be other problems with permissions and running PHP/CGI/PERL scripts.
 
I had the same a while back and discussed it in another topic you started :p

http://www.directadmin.com/forum/showthread.php?t=37282&page=3#45

Basicly its changing in httpd.conf

RUidGid apache apache

into

RUidGid apache access

Resulting in ip/~user working again, BUT all requests under ip/~user are then under the user apache. Normal requests at domains are still under the user.

So I figured its either having ip/~user working with user apache, or have it not working.

Its because the virtual hosts are configured to have valid RUidGid users under domain requests. When theres an IP requests, these virtual hosts are not called so the RUidGid doesn't change. If you grant 'access' access (the secure_access_group setting) it works because then ip requests has valid rights.
 
And what about PHP scripts? Are they working ok, even they're owned by user (customer user), not apache? Do they have all rights to write and read?
 
Normal php scripts work fine, if you need to write a cache for example you need to chown the dir to group access and give the dir group rights (770, normally 700 would be enough).

Under IP requests, it then makes files with chown apache:access instead of the user:user chown under domain requests.

Tested it on a Smarty cache and a phpbb board and they seem to work with it. Not sure if there are any consequences, maybe it will overwrite certain cache files or something, I don't know.
 
Last edited:
No user, but root can change group to access.
Any way if it works for you, that's ok. We do not grant access to sites by IP to our customers.
 
I had the same a while back and discussed it in another topic you started :p

http://www.directadmin.com/forum/showthread.php?t=37282&page=3#45

Basicly its changing in httpd.conf

RUidGid apache apache

into

RUidGid apache access

Resulting in ip/~user working again, BUT all requests under ip/~user are then under the user apache. Normal requests at domains are still under the user.

So I figured its either having ip/~user working with user apache, or have it not working.

Its because the virtual hosts are configured to have valid RUidGid users under domain requests. When theres an IP requests, these virtual hosts are not called so the RUidGid doesn't change. If you grant 'access' access (the secure_access_group setting) it works because then ip requests has valid rights.
In which file I need to edit that?

I've searched in:
/etc/httpd/conf/http.conf
But I didn't find anything...
 
It is /etc/httpd/conf/ips.conf. But it should not be directly edited.
Made changes in /usr/local/directadmin/data/templates/custom/ips_virtual_host.conf and edit IPs in Directadmin afterwards.
 
It is /etc/httpd/conf/ips.conf. But it should not be directly edited.
Made changes in /usr/local/directadmin/data/templates/custom/ips_virtual_host.conf and edit IPs in Directadmin afterwards.

I've created the file ips_virtual_host.conf in the custom directory and restarted the Apache but I still can't access to sits through the IP.

This is the file content:
Code:
<VirtualHost |IP|:80>
    ServerName shared.domain
    ScriptAliasMatch ^/~([^/]+)/+cgi-bin/+(.*) /home/$1/public_html/cgi-bin/$2
    AliasMatch ^/~([^/]+)(/.*)* /home/$1/public_html$2
    DocumentRoot |DOCROOT|
|*if APACHE_VER="2.0"|
    #SuexecUserGroup |USER| |GROUP|
    RMode config
    RUidGid apache access
    RGroups apache 
|*else|
    User |USER|
    Group |GROUP|
|*endif|
    CustomLog /var/log/httpd/homedir.log homedir
</VirtualHost>

<VirtualHost |IP|:443>
    SSLEngine on
    SSLCertificateFile |CERT|
    SSLCertificateKeyFile |KEY|
    ServerName shared.domain
    ScriptAliasMatch ^/~([^/]+)/+cgi-bin/+(.*) /home/$1/public_html/cgi-bin/$2
    AliasMatch ^/~([^/]+)(/.*)* /home/$1/public_html$2
    DocumentRoot |DOCROOT|
|*if APACHE_VER="2.0"|
    #SuexecUserGroup |USER| |GROUP|
    RMode config
    RUidGid apache apache
    RGroups apache 
|*else|
    User |USER|
    Group |GROUP|
|*endif|
    CustomLog /var/log/httpd/homedir.log homedir
</VirtualHost>

and what you meant by "edit IPs in Directadmin afterwards"?
 
Directadmin does apply changes only on specific events.
Login as Admin and in IP Manager add a fake IP (e.x. 127.0.0.2), then delete.
After that /etc/httpd/conf/ips.conf will be rewritten.
 
Directadmin does apply changes only on specific events.
Login as Admin and in IP Manager add a fake IP (e.x. 127.0.0.2), then delete.
After that /etc/httpd/conf/ips.conf will be rewritten.
And what about the file I've created. it's okay?
 
Back
Top