Page 1 of 1

How to create nginx.conf to different domains?

Posted: Wed Nov 30, 2016 8:41 pm
by neto737
Hi,

I have many domains, and right now I want to use NGINX + PHP-FPM.

Before I decide use nginx, my website has used apache2 (httpd).

Here is the htaccess:

Code: Select all

<ifModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTPS}:s on:(s)
RewriteRule ^ http%1://%1%{REQUEST_URI} [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f

</ifModule>

RewriteEngine On

ErrorDocument 404 /errors/404.php
ErrorDocument 403 /errors/403.php

<FilesMatch "\.tpl$">
    Order Allow,Deny
    Deny from all
</FilesMatch>

Options -Indexes

RewriteRule ^(.*)\.html $1\.php

#SITE REWRITE RULES
RewriteRule ^home(.*)$ index.php
RewriteRule ^ref/(.*)$ index.php?ref=$1
RewriteRule ^dashboard(|/)$ dashboard.php
RewriteRule ^claim(|/)$ claim.php
RewriteRule ^account(|/)$ account.php
RewriteRule ^account/withdraw/(.*)$ account.php?withdraw=$1
RewriteRule ^logout(|/)$ logout.php
RewriteRule ^maintenance(|/)$ maintenance.php

RewriteRule ^list/(.*)$ faucetList/faucetList.php?coin=$1

#ADMIN REWRITE RULES
RewriteRule ^admin/stats(|/)$ admin/stats.php
RewriteRule ^admin/login(|/)$ admin/index.php
RewriteRule ^admin/settings(|/)$ admin/settings.php
RewriteRule ^admin/ads(|/)$ admin/ads.php
RewriteRule ^admin/ban(|/)$ admin/ban.php
RewriteRule ^admin/users(|/)$ admin/users.php
RewriteRule ^admin/logout(|/)$ admin/logout.php
And the config to nginx:

Code: Select all

# nginx configuration
error_page 404 /errors/404.php;
error_page 403 /errors/403.php;
autoindex off;
    location / {
        if ($http_host ~* "^www\.(.+)$") {
            rewrite ^(.*)$ http%1://%1$request_uri redirect;
        }
        if (!-e $request_filename){
            rewrite ^/(.*)\.html /$1\.php;
        }
    }
    location /home {
        rewrite ^/home(.*)$ /index.php;
    }
    location /ref {
        rewrite ^/ref/(.*)$ /index.php?ref=$1;
    }
    location /dashboard {
        rewrite ^/dashboard(|/)$ /dashboard.php;
    }
    location /faucet {
        rewrite ^/faucet(|/)$ /faucet.php;
    }
    location /claim {
        rewrite ^/claim(|/)$ /claim.php;
    }
    location /account {
        rewrite ^/account(|/)$ /account.php;
        rewrite ^/account/withdraw/(.*)$ /account.php?withdraw=$1;
    }
    location /logout {
        rewrite ^/logout(|/)$ /logout.php;
    }
    location /maintenance {
        rewrite ^/maintenance(|/)$ /maintenance.php;
    }
    location /list {
        rewrite ^/list/(.*)$ /faucetList/faucetList.php?coin=$1;
    }
    location /admin {
        rewrite ^/admin/stats(|/)$ /admin/stats.php;
        rewrite ^/admin/login(|/)$ /admin/index.php;
        rewrite ^/admin/settings(|/)$ /admin/settings.php;
        rewrite ^/admin/ads(|/)$ /admin/ads.php;
        rewrite ^/admin/ban(|/)$ /admin/ban.php;
        rewrite ^/admin/users(|/)$ /admin/users.php;
        rewrite ^/admin/logout(|/)$ /admin/logout.php;
    }
    location ~ \.tpl$ {
        deny all;
    }
But, how I need to add this config to my domains? I've tried to add a "domain.tld.conf" on /etc/nginx/conf.d/ but doesn't work. After that, I've tried to add "nginx.batfaucet.xyz.conf" on /home/admin/conf/web/ but it doesn't work too.

If has any method to upload the config directly to wwwroot would be best method.

Any ideas?

Regards,
neto737