Reverse-proxy NGINX + Apache on Directadmin powered server with CB 2.x

A guide which you followed from the first post is just only an instruction how to install nginx+apache on directadmin powered server with the help of custombuild script. I don't work for directadmin and did not write custombuild script. I'm a third party supporter, who offer free help on directadmin forums and private support in terms of commerce service.

In this case, I'd suggest that you:
1. rename or move /etc/nginx/.
2. run the commands from the guide once more. With this you will get all the configs in /etc/nginx/.

And let's see will it solve your issue or not.
 
A guide which you followed from the first post is just only an instruction how to install nginx+apache on directadmin powered server with the help of custombuild script. I don't work for directadmin and did not write custombuild script. I'm a third party supporter, who offer free help on directadmin forums and private support in terms of commerce service.

In this case, I'd suggest that you:
1. rename or move /etc/nginx/.
2. run the commands from the guide once more. With this you will get all the configs in /etc/nginx/.

And let's see will it solve your issue or not.

)) I know and respect that, i just followed them and they did not work for me. I not hold u responsible ))

I did as u said (( but it did not work and i reverted it already

let me do that again...

done

http://pastebin.com/0MZKvMFJ

Ill try to add that file and see if it will work, but its a strange assumption from nginx
 
Last edited:
mmmm i dont get it but if its so hard to do, ill better not do it )))

the reference to the username seems to be an error where the username is actually a variable that does not get picked up.

Imback to apache only and will post in the custom build forum


thanks
 
yes

[root@server /]# ls /usr/local/directadmin/scripts/custom/
block_ip.sh brute_force_notice_ip.sh README show_blocked_ips.sh unblock_ip.sh [root@server /]#
 
In this case I'd suggest that you run

Code:
echo "action=rewrite&value=nginx" >> /usr/local/directadmin/data/task.queue
/usr/local/directadmin/dataskq d800 | tee -a /root/dataskq.out

Would be nice to see /root/dataskq.out (hide any passwords if present any).
 
In this case I'd suggest that you run

Code:
echo "action=rewrite&value=nginx" >> /usr/local/directadmin/data/task.queue
/usr/local/directadmin/dataskq d800 | tee -a /root/dataskq.out

Would be nice to see /root/dataskq.out (hide any passwords if present any).

Ok but i reverted back already, should i first try again and then do that command?
 
did it without trying to setup nginx

Debug mode. Level 800

root priv set: uid:0 gid:0 euid:0 egid:0
pidfile written
staring queue
dataskq: command: action=rewrite&value=nginx
done queue
 
Ok i solved it

Indeed just by creating that nginx php config file in the directory of the non existing user.
Silly tha it was needed but glad that its working.

A huge improvement!! I feel its 50% faster !!

I want to thank you for helping, it means a lot to have people like u

Thanks and best wishes
 
I'm glad. But still I wonder why directadmin tries to include that file. I guess directadmin staff should do an investigation.
 
Hello , i install nginx_apache from custombuild but after afew hours i see that my site very slow and page loads too bad ,
is this possible to help me on this ?
thanks
 
Hello,

Your description is not enough even to guess what your issue might be caused by. For your own diagnose you could probably use online tools such as http://tools.pingdom.com/fpt/ https://developers.google.com/speed/pagespeed/insights/ and server tools such as top/htop/mysqltuner/server-status, etc.

If you need a private help so that somebody log into your server, investigate your issue and fix it, then you need to hire some of us (including me) here who offers issue solving as a commercial service. Please feel free to contact those who you trust more for a quote.
 
New Installation Speed problem!

I installed Nginx as R-Proxy on apache 2.4 PHP 5.5.24 with first post of this topic guide.
Thanks to Alex and Martynas

Code:
./build set webserver nginx_apache
./build nginx_apache
./build rewrite_confs

But result is really strange because page loading now is really slow and awful. before Nginx everything was normal.(not fast and not slow)
I was waiting to make sure nginx is stable on DA about a year and installed on first server with no problem, but this server have problem.
I checked both domain.com:80 and domain.com:8080 same load speed.

my /etc/nginx/nginx.conf :
Code:
http {
    proxy_connect_timeout       600;
    proxy_send_timeout          600;
    proxy_read_timeout          600;
    send_timeout                600;
    fastcgi_buffers 8 16k;
    fastcgi_buffer_size 32k;
    fastcgi_connect_timeout 600;
    fastcgi_send_timeout 600;
    fastcgi_read_timeout 600;
    include       /etc/nginx/mime.types;
    # For user configurations not maintained by DirectAdmin. Empty by default.
    include /etc/nginx/nginx-includes.conf;
    # Supplemental configuration
    include /etc/nginx/nginx-modsecurity-enable.conf;
    include /etc/nginx/nginx-defaults.conf;
    include /etc/nginx/nginx-gzip.conf;
    include /etc/nginx/nginx-proxy.conf;
    include /etc/nginx/directadmin-ips.conf;
    include /etc/nginx/directadmin-settings.conf;
    include /etc/nginx/nginx-vhosts.conf;
    include /etc/nginx/directadmin-vhosts.conf;}


This is /var/log/httpd/error_log output:
Code:
[Sun Aug 02 09:49:20.381881 2015] [mpm_prefork:notice] [pid 27240] AH00173: SIGHUP received.  Attempting to restart
[Sun Aug 02 09:50:19.046330 2015] [auth_digest:notice] [pid 27240] AH01757: generating secret for digest authentication ...
[Sun Aug 02 09:50:20.076481 2015] [ssl:warn] [pid 27240] AH01909: www.example.com:8081:0 server certificate does NOT include an ID which matches the server name
[Sun Aug 02 09:50:20.076770 2015] [lbmethod_heartbeat:notice] [pid 27240] AH02282: No slotmem from mod_heartmonitor
[Sun Aug 02 09:50:20.076988 2015] [:notice] [pid 27240] mod_ruid2/0.9.8 enabled
[Sun Aug 02 09:50:20.088680 2015] [:notice] [pid 27240] mod_bw : Memory Allocated 1200 bytes (each conf takes 48 bytes)
[Sun Aug 02 09:50:20.088717 2015] [:notice] [pid 27240] mod_bw : Version 0.92 - Initialized [25 Confs]
[Sun Aug 02 09:50:20.095187 2015] [mpm_prefork:notice] [pid 27240] AH00163: Apache/2.4.16 (Unix) OpenSSL/1.0.1e-fips PHP/5.5.24 configured -- resuming normal operations
[Sun Aug 02 09:50:20.095261 2015] [core:notice] [pid 27240] AH00094: Command line: '/usr/sbin/httpd -D SSL'
[Sun Aug 02 09:50:30.533596 2015] [core:notice] [pid 27240] AH00052: child pid 11862 exit signal Segmentation fault (11)
[Sun Aug 02 10:06:39.581396 2015] [core:notice] [pid 27240] AH00052: child pid 12992 exit signal Segmentation fault (11)
Output file write error --- out of disk space?
[Sun Aug 02 10:24:38.158173 2015] [core:notice] [pid 27240] AH00052: child pid 14241 exit signal Segmentation fault (11)
[Sun Aug 02 10:25:59.711144 2015] [core:notice] [pid 27240] AH00052: child pid 14333 exit signal Segmentation fault (11)
Output file write error --- out of disk space?
[Sun Aug 02 10:30:20.729792 2015] [core:notice] [pid 27240] AH00052: child pid 14310 exit signal Segmentation fault (11)
[Sun Aug 02 10:31:28.422388 2015] [core:notice] [pid 27240] AH00052: child pid 14650 exit signal Segmentation fault (11)
[Sun Aug 02 10:31:32.647048 2015] [core:notice] [pid 27240] AH00052: child pid 14629 exit signal Segmentation fault (11)
[Sun Aug 02 10:36:52.624431 2015] [core:notice] [pid 27240] AH00052: child pid 14742 exit signal Segmentation fault (11)
Im sure there is no disk space problem:
Code:
df -ih
Filesystem     Inodes IUsed IFree IUse% Mounted on
/dev/sda2         34M  2.3M   32M    7% /
tmpfs            973K     7  973K    1% /dev/shm
df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2       539G  336G  177G  66% /
tmpfs           3.8G   24K  3.8G   1% /dev/shm


I also got permission problem on some web sites after ./build rewrite_confs, css+ images had problem to load they was changed to 711 and 611. solved with chmod one by one in /home. JFYI if you have same problem cd domain/public_html and run:
Code:
find * -type d -exec chmod 755 {} \;
find * -type f -exec chmod 644 {} \;

whats wrong? did I forget something?
 
Last edited:
Hi

So after playing arround and trying nginx only (untill there are tools to help me deal with rewrites ill pass on that)
im now back to apache + nginx, not so fast as nginx but easier to manage

However now i have a problem where certain css files are generating a 404 error and a really ugly site
the files are present on the server and it worked, but for some reason it stopped now.

I tried everything i could read here but no luck

per example: www -- yumminova -- eu

Could someone please helpme??
 
Hi

So after playing arround and trying nginx only (untill there are tools to help me deal with rewrites ill pass on that)
im now back to apache + nginx, not so fast as nginx but easier to manage

However now i have a problem where certain css files are generating a 404 error and a really ugly site
the files are present on the server and it worked, but for some reason it stopped now.

I tried everything i could read here but no luck

per example: www -- yumminova -- eu

Could someone please helpme??



So i looked again and its funny:

if i look at the nginx log and httpd log i see that the resource is found on httpd but not on nginx

So httpd will state

141.101.99.245 - - [08/Aug/2015:09:47:45 +0200] "GET /wp-content/themes/sip_telecom_reseller/js/zerif.js HTTP/1.0" 200 281 "http://www.yumminova.eu/"


But nginx says

2015/08/08 09:47:45 [error] 17561#0: *305 openat() "/var/www/html/wp-content/themes/sip_telecom_reseller/js/zerif.js" failed (2: No such file or directory),
 
This applies to apche+nginx as reverse proxy



I finally gave up so that at least my websites work and discovered smth that works (not that tis could not work)

seperate proxy server

I installed a small vps with nginx only and followed these instructions:

install nginx (
Code:
yum install nginx
)
clear the config file (
Code:
echo > /etc/nginx/nginx.conf
)
edit the config file to have this in it:


Do it easy with

Code:
cat <<EOT >> /etc/nginx/nginx.conf
#user apache apache;

worker_processes 4; # Set it according to what your CPU have. 4 Cores = 4
worker_rlimit_nofile 8192;

pid /var/log/nginx.pid;

events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;

log_format main ‘$remote_addr – $remote_user [$time_local] ‘
‘”$request” $status $body_bytes_sent “$http_referer” ‘
‘”$http_user_agent” “$http_x_forwarded_for”‘;

server_tokens off;
access_log /var/log/nginx_access.log main;
error_log /var/log/nginx_error.log debug;

server_names_hash_bucket_size 64;
sendfile on;
tcp_nopush on;
tcp_nodelay off;
keepalive_timeout 30;
gzip on;
gzip_comp_level 9;
gzip_proxied any;

proxy_buffering on;
proxy_cache_path /usr/local/nginx/proxy_temp levels=1:2 keys_zone=one:15m inactive=7d max_size=1000m;
proxy_buffer_size 16k;
proxy_buffers 100 8k;
proxy_connect_timeout 60;
proxy_send_timeout 60;
proxy_read_timeout 60;

server {
# change the ip (xxx) in the next line to the ip of the server where u instal

listen xxx.xxx.xxx.xxx:80 default rcvbuf=8192 sndbuf=16384 backlog=32000; 
server_name domain.name _ ; # “_” is for handle all hosts that are not described by server_name
charset off;
access_log /var/log/nginx_host_general.access.log main;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://xxx.xxx.xxx.xxx; # Set the ip (xxx) to the ip of the box serving your websites before proxy-ing
client_max_body_size 16m;
client_body_buffer_size 128k;
proxy_buffering on;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 120;
proxy_buffer_size 16k;
proxy_buffers 32 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
}
# below is include so that you can have separate setting per vhost. This will only work on single server setups
include /usr/local/directadmin/data/users/*/nginx.conf;
}
EOT

Code:
service nginx start

Changed over the DNS to reflect the ip address of the new vps and it rocks, no problem at all.

I now have a apache only server as backend with a proxy in front of it.

Single server

This setup works on our Apache server as well (without extra server for proxy) but it seems slower compared to adding an extra server )), while changing the ports in the config, where apache would listen on port 81 or 8080 and nginx on port 80 but ill try that.

Please make sure that u change port80=80 in directadmin.conf to the value wanted for Apache and restart httpd then, i needed to change it in /etc/httpd/conf/httpd.conf as well to get success

Pros: It does not need a lot of config, u can work as u are used to
Cons: Its not included in custombuild, u cant easily have custom configs if using external proxy

Im not that techie so i might get some comments but i welcome them, to me it seems a nice and clean way of doing it
 
Last edited:
But nginx says

2015/08/08 09:47:45 [error] 17561#0: *305 openat() "/var/www/html/wp-content/themes/sip_telecom_reseller/js/zerif.js" failed (2: No such file or directory),

Hello,

I guess nginx templates or configs are incorrect on your server as nginx tries to find a file /wp-content/themes/sip_telecom_reseller/js/zerif.js in /var/www/html/, not in /home/username/domain/domainname/public_html/.
 
If you're trying to setup WordPress redirects in your user nginx.conf file, but this breaks your webapps links, like /roundcube, you must do it in a specific way, or your WP rewrites are going to override the /roundcube settings, thus breaking them.

If this is the case you might need to check this: http://help.directadmin.com/item.php?id=562
 
Hello,

I guess nginx templates or configs are incorrect on your server as nginx tries to find a file /wp-content/themes/sip_telecom_reseller/js/zerif.js in /var/www/html/, not in /home/username/domain/domainname/public_html/.

Thanks for responding! I have no strange tempates, custom is empty

where could i check that??

I have just tested the above story on single server and it works, but it is slower then with an extra server in the path
 
Back
Top