[nginx] only one domain per user rewrite?

Frej

Verified User
Joined
Jun 15, 2008
Messages
155
so as far as im aware theres onle 1 nginx rewrite per domain allowed. It is because otherwise custombuild would not work in automated
way (e.g. it will fail when there would be no rewrite for new domain).
Current rewrite for user starsama is /usr/local/directadmin/data/users/starsama/nginx-rewrites.conf and it set for blog only.
but under that account i have another domain which is vbulletin

so are there only two choises, either adding this domain as separate user or breaking custombuild by pointing to domain only configuration file?
 
Last edited:
Go to the old Custom HTTPD Configurations, and there you can set rewrites/rules per domain.
 
Code:
# Auto generated apache config file by DirectAdmin version 1.44.0
# Modifying this file is not recommended as any changes you make will be
# overwritten when the user makes any changes to his/her website

# For global config changes that affect all Users, see this guide:
# [URL]http://help.directadmin.com/item.php?id=2[/URL]
# For local config changes that only affect one User, see this guide:
# [URL]http://help.directadmin.com/item.php?id=3[/URL]


server
{
    listen 94.1.2.3:80;
    server_name domain.com [URL="http://www.domain.com(the rewrite working on this domain)"]www.domain.com(the rewrite working on this domain)[/URL] ;
    access_log /var/log/nginx/domainswww.domain.com(the rewrite working on this domain).log;
    access_log /var/log/nginx/domains/www.domain.com(the rewrite working on this domain).bytes bytes;
    error_log /var/log/nginx/domains/www.domain.com(the rewrite working on this domain)error.log;
    root /home/starsama/domains/www.domain.com(the rewrite working on this domain)/public_html;
    index index.php index.html index.htm;
# for future
#    include /usr/local/directadmin/data/users/starsama/nginx-www.domain.com(the rewrite working on this domain).conf;
    include /usr/local/directadmin/data/users/starsama/nginx-rewrites.conf;
        # use fastcgi for all php files
        location ~ \.php$
        {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            include /etc/nginx/fastcgi_params;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include /etc/nginx/nginx_limits.conf;
            if (-f $request_filename)
            {
                fastcgi_pass unix:/usr/local/php54/sockets/starsama.sock;
            }
        }
    # deny access to apache .htaccess files
    location ~ /\.ht
    {
        deny all;
    }
    include /etc/nginx/webapps.conf;
}

server
{
    listen 94.1.2.3:443 ssl;
    server_name trap-heaven.com [URL="http://www.domain.com"]www.domain.com[/URL] ;
    access_log /var/log/nginx/domains/www.domain.com.log;
    access_log /var/log/nginx/domains/www.domain.com.bytes bytes;
    error_log /var/log/nginx/domains/www.domain.com.error.log;
    root /home/starsama/domains/www.domain.com/private_html;
    index index.php index.html index.htm;
    ssl on;
    ssl_certificate /etc/httpd/conf/ssl.crt/server.crt;
    ssl_certificate_key /etc/httpd/conf/ssl.key/server.key;
    ssl_session_timeout 5m;
    ssl_protocols SSLv3 TLSv1;
    ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
    ssl_prefer_server_ciphers on;
        # use fastcgi for all php files
        location ~ \.php$
        {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            include /etc/nginx/fastcgi_params;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include /etc/nginx/nginx_limits.conf;
            if (-f $request_filename)
            {
                fastcgi_pass unix:/usr/local/php54/sockets/starsama.sock;
            }
        }
    # deny access to apache .htaccess files
    location ~ /\.ht
    {
        deny all;
    }
    include /etc/nginx/webapps.conf;
}

server
{
    listen 94.1.2.3:80;
    server_name lionsprideinn.com [URL="http://www.domain2.com"]www.domain2.com[/URL] ;
    access_log /var/log/nginx/domains/domain2.log;
    access_log /var/log/nginx/domains/domain2.bytes bytes;
    error_log /var/log/nginx/domains/domain2.error.log;
    root /home/starsama/domains/domain2/public_html;
    index index.php index.html index.htm;
# for future
#    include /usr/local/directadmin/data/users/starsama/nginx-domain2.conf;
    include /usr/local/directadmin/data/users/starsama/nginx-rewrites.conf;
        # use fastcgi for all php files
        location ~ \.php$
        {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            include /etc/nginx/fastcgi_params;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include /etc/nginx/nginx_limits.conf;
            if (-f $request_filename)
            {
                fastcgi_pass unix:/usr/local/php54/sockets/starsama.sock;
            }
        }
    # deny access to apache .htaccess files
    location ~ /\.ht
    {
        deny all;
    }
    include /etc/nginx/webapps.conf;
}

server
{
# custom rewrites
if (!-e $request_filename)
{
rewrite "^/(.*)$" "/blog/index.php";
}
    listen 94.1.2.3:80;
    server_name valsnaughtyemporium.com [URL="http://www.domain3(the one i want rewrite).com"]www.domain3(the one i want rewrite).com[/URL] ;
    access_log /var/log/nginx/domains/www.domain3(the one i want rewrite).log;
    access_log /var/log/nginx/domains/www.domain3(the one i want rewrite).bytes bytes;
    error_log /var/log/nginx/domains/www.domain3(the one i want rewrite).error.log;
    root /home/starsama/domains/www.domain3(the one i want rewrite)/public_html;
    index index.php index.html index.htm;
# for future
#    include /usr/local/directadmin/data/users/starsama/nginx-www.domain3(the one i want rewrite).conf;
    include /usr/local/directadmin/data/users/starsama/nginx-rewrites.conf;
        # use fastcgi for all php files
        location ~ \.php$
        {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            include /etc/nginx/fastcgi_params;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include /etc/nginx/nginx_limits.conf;
            if (-f $request_filename)
            {
                fastcgi_pass unix:/usr/local/php54/sockets/starsama.sock;
            }
        }
    # deny access to apache .htaccess files
    location ~ /\.ht
    {
        deny all;
    }
    include /etc/nginx/webapps.conf;
}
 
Last edited by a moderator:
and in your Custom HTTPD Configurations for that domain?
 
Hello,

I'm not sure I'm fully understanding the question...
A) Are you referring to an issue with the DA template system? If yes, see below.

B) Else, are you referring to issues when adding multiple rewrites in a server {} context?
If you want multiple rewrite entries, you'd need to have different conditions, else the first rewrite would always take precedence.

-----
If you're reporting a DA template issue, you should be able to add code to:
Admin Level -> Custom Httpd Config -> domain.com

for each domain you want, and have that code added to the given domains.
I just tested with one of our test boxes.. added different custom code to each domain under one User account, and the custom code showed up in each domain as intended.

Note that we are using the latest pre-release binaries/templates, so maybe try updating to the pre-release templates, in case there were changes to the binaries/templates which allowed it to work for me.
If you do get the pre-release binaries, be sure to delete your custom templates, and rebuild them again from our current nginx_*.conf templates.


1) To confirm, you're trying to add this code to all domains under the single User account?
Code:
# custom rewritesif (!-e $request_filename)
{
	rewrite "^/(.*)$" "/blog/index.php";
}
2) Can you confirm that all required domains have the custom code added?
Code:
cd /usr/local/directadmin/data/users/[B]username[/B]/domains
ls -la *.cust_nginx
cat *.cust_nginx

3) I noticed this custom code:
Code:
# for future
#    include /usr/local/directadmin/data/users/starsama/nginx-www.domain3(the one i want rewrite).conf;
    include /usr/local/directadmin/data/users/starsama/nginx-rewrites.conf;
Was this code added via the data/templates/custom/nginx_*.conf files?

If yes, confirm each of the 4 nginx_*.conf files to the originals to ensure there are no other changes than just your own changes.



I'm not sure if I answered your question, so please let me know if I've misunderstood what you need or if it's a DA issue or not.

John
 
Back
Top