logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Nginx vs Other Webservers on WINDOWS ONLY Page Previous  1, 2, 3, 4, 5, 6  Next
Author
ng4win



Joined: 25 May 2014
Posts: 78

PostPosted: Thu 29 May '14 21:06    Post subject: Reply with quote

Here's a nice FYI to get sustained performance with nginx for Windows/php, http://forum.nginx.org/read.php?2,242895,243597#msg-243597 which I wrote a while ago, also works for RoR.
Back to top
C0nw0nk



Joined: 07 Oct 2013
Posts: 241
Location: United Kingdom, London

PostPosted: Thu 29 May '14 22:01    Post subject: Reply with quote

I have been after that for a while is the "19001", "19002", "19003", "19004" ranges on each multi run a port to open that php process under ?


Also why run them under different users whats wrong with one being system the other being root ?

I am also curious with that script if a php process crashes does it boot it up again via the loop ?

You should add those bat files to your Nginx builds folder and just add a readme that mentions to people to download a put a non threaded php install somewhere.

Becomes a all in one nginx bundle Very Happy

Also a bat/cmd file in your Nginx zip that contains this would be nice.

Code:
taskkill /f /im nginx_basic.exe


Helps to kill all nginx processes when you use "worker_processes auto;"
Back to top
ng4win



Joined: 25 May 2014
Posts: 78

PostPosted: Thu 29 May '14 23:25    Post subject: Reply with quote

C0nw0nk wrote:
I have been after that for a while is the "19001", "19002", "19003", "19004" ranges on each multi run a port to open that php process under ?

Yep, you get x amount of fpm processes which nginx will cycle through as a pool, add xcache or apc and your of flying Mr. Green

Quote:
Also why run them under different users whats wrong with one being system the other being root ?

When one part gets hacked all of it gets hacked and you never ever want an internet facing application running as system/admin (= root), here each process runs under a very restricted user and each component is a different such user.

Quote:
I am also curious with that script if a php process crashes does it boot it up again via the loop ?

Yep.

Quote:
You should add those bat files to your Nginx builds folder and just add a readme that mentions to people to download a put a non threaded php install somewhere.

Becomes a all in one nginx bundle Very Happy

Work for that is in progress.

Quote:
Also a bat/cmd file in your Nginx zip that contains this would be nice.

Code:
taskkill /f /im nginx_basic.exe


Helps to kill all nginx processes when you use "worker_processes auto;"

Processviewer has a cmd tool pv.exe we use which is much better, but all in all this stuff will be part of the installer when we eventually finish it Very Happy
Back to top
gijs



Joined: 27 Apr 2012
Posts: 189
Location: The Netherlands

PostPosted: Mon 02 Jun '14 1:38    Post subject: Reply with quote

Can someone guide me through the process if settings nginx up in front of my Apache server (as a reverseproxy)?
I currently have my website hosted on apache 2.4 and have a virtualhost with SSL support and multiple domains.

If I understood C0nw0nk reply, I should change nginx config(nginx-win.conf) to this:

Code:
listen       80;
server_name  www.elitegameservers.com   elitegameservers.com;
root   C:/Program Files/Apache Software Foundation/Apache24/htdocs/site 3;
#####Place everything for that host here roots configs etc######
}
server {
listen       80;
server_name  www.domain1   domain1   static.domain1;
root   C:/Program Files/Apache Software Foundation/Apache24/htdocs/site 1;
#####Place everything for that host here roots configs etc######
}
server {
listen       80;
server_name  hac2.domain2;
root   D:/hac2;
#####Place everything for that host here roots configs etc######
}
server {
listen       80;
server_name  www.domain3   domain3;
root   C:/Program Files/Apache Software Foundation/Apache24/htdocs/site 5;
#####Place everything for that host here roots configs etc######


Question 1: How can I change listen to only listen to a specific Ipv4 and Ipv6 address at port 80?

Question 2: How do I add SSL support for certain domains?

I guess it is the same as with the virtual hosts but adding:
Code:
    #    listen       443 ssl spdy;
    #    server_name  localhost;

    #    ssl                  on;
    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_timeout  5m;

    #    ssl_protocols  SSLv2 SSLv3 TLSv1;
    #    ssl_ciphers  RC4:HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers   on;

Is that correct? What is the nginx equivalent for: SSLCACertificateFile and SSLCertificateChainFile?

Question 3: My website also uses PHP, is this proxied automatically or do I need to change something to get this to work as well?

Code:
        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

I suppose I need to uncomment this.
But I don't think this will work with my Apache vhost because it ignores the listening IP's and uses 127.0.0.1 instead.

+ how do I change the port? Since apache is going to run on port 8000.

Question 4: Will my .htaccess work because of the proxy? or do I need to make certain changes to the nginx config for this?

I suppose I need to uncomment:
Code:
        #location ~ /\.ht {
        #    deny  all;


Question 5: Does nginx basic lack other functions except lua support?
Back to top
C0nw0nk



Joined: 07 Oct 2013
Posts: 241
Location: United Kingdom, London

PostPosted: Mon 02 Jun '14 1:48    Post subject: Reply with quote

You have to change your apache port to something else. (8080, 8000 etc.)

Take my config and just change the bits you need to suit your needs i do media streaming so i have allot of mp4, flv etc configs to limit bandwidth outputs. Remove what you don't need have a play about.

Code:
#user  nobody;
worker_processes  auto;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

error_log  logs/error.log  crit;

#pid        logs/nginx.pid;


events {
    worker_connections  16384;
   multi_accept on;
}
#worker_rlimit_nofile   20000000;

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

access_log off;

    sendfile   on;
    tcp_nopush   on;
   tcp_nodelay   on;

   keepalive_requests 100000;
   client_max_body_size 500m;
   server_tokens off;
   etag off;

open_file_cache          max=900000 inactive=10m;
open_file_cache_valid    20m;
open_file_cache_min_uses 1;
open_file_cache_errors   on;

proxy_connect_timeout 3600;
proxy_send_timeout 3600;
proxy_read_timeout 3600;
send_timeout 3600;

proxy_cache_path C:/Users/root/Desktop/nginx/cache levels=1:2 keys_zone=my-cache:8m max_size=1000m inactive=600m;
proxy_temp_path C:/Users/root/Desktop/nginx/temp/proxy_temp;
#upstream web_rack {
#    server 127.0.0.1:80;
#   server 127.0.0.1:8000;
#}
    server {
        listen   80;
      listen   [::]:80;
        server_name  domain.com   www.domain.com;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;
      root   z:/server/websites/ps/public_www;
      index index.php index.html index.htm default.html default.htm;
      #index  index.php;
        location / {
      root   z:/server/websites/ps/public_www;
      #try_files $uri $uri/ /index.php;
      proxy_set_header X-Real-IP  $remote_addr;
      proxy_set_header X-Forwarded-For $remote_addr;
      proxy_set_header Host $host;
      #proxy_pass http://web_rack;
      proxy_pass   http://172.16.0.1:8000;
      expires 10s;
      max_ranges 0;
      # Define which cache to use
        proxy_cache my-cache;
        # Define which responses to cache and for how long
        proxy_cache_valid  200 302  5m;
        proxy_cache_valid  404      5m;

        # Don't cache if our headers (or cookie) are present
        proxy_no_cache $upstream_http_x_dont_cache_me $cookie_jnocache;
        proxy_cache_bypass $upstream_http_x_dont_cache_me $cookie_jnocache;
         
        # Ignore the standard no-cache headers - these will still be sent to the browser
        proxy_ignore_headers X-Accel-Expires Expires Cache-Control;

        # Don't send our custom header to the browser
        proxy_hide_header X-Dont-Cache-Me;

        # This next line is important if we're planning on caching for more than one site on the server
        proxy_cache_key "$scheme$host$request_uri";
      proxy_cache_use_stale updating;
        }
      location ~ \.flv$ {
      flv;
      limit_rate_after 1m;
      limit_rate 200k;
      root   z:/server/websites/ps/public_www;
      expires max;
      }
      location ~ \.mp4$ {
      mp4;
      #mp4_max_buffer_size 99999M;
      limit_rate_after 1m;
      limit_rate 200k;
      root   z:/server/websites/ps/public_www;
      expires max;
      }
      location ~ \.gif$ {
      #limit_rate 50k;
      root   z:/server/websites/ps/public_www;
      expires max;
      }
      location ~* \.(avi|m4v|mov|divx|webm|ogg|mp3|mpeg|mpg|zip|rar)$ {
      #limit_rate 90k;
      root   z:/server/websites/ps/public_www;
      expires max;
      }

      location ~* \.(ico|png|jpg|jpeg|gif|flv|mp4|avi|m4v|mov|divx|webm|ogg|mp3|mpeg|mpg|swf|css|js|txt|zip|rar|xml)$ {
      root   z:/server/websites/ps/public_www;
      expires max;
      }
        location ~ /\.ht {
      #deny  all;
      return 404;
        }
      location ~ ^/(xampp|security|phpmyadmin|licenses|webalizer|server-status|server-info|cpanel|configuration.php) {
      #deny  all;
      return 404;
      }
    }
}



My hard drive is z since my nginx is setup for mapped network hard drives also my apache runs on port 8000.

Also i recommend you disable my proxy caching config or set it up for your own needs.
Back to top
gijs



Joined: 27 Apr 2012
Posts: 189
Location: The Netherlands

PostPosted: Mon 02 Jun '14 2:18    Post subject: Reply with quote

I guess your setup is for a single domain.

It did answer my question 1, I think Razz
Code:

listen       Ipv4:80;
listen [Ipv6]:80;

Same as with Apache virtualhost?

If I set all my virtualhosts in apache to listen to 127.0.0.1 at port 8000 will this work:
Code:
location ~ \.php$ {
proxy_pass   http://127.0.0.1:8000;

Does it send on the domain name so it is automatically forwarded to the correct vhost?

Would also like to get a reply for my other questions.
Back to top
ng4win



Joined: 25 May 2014
Posts: 78

PostPosted: Mon 02 Jun '14 9:27    Post subject: Reply with quote

gijs wrote:
Question 4: Will my .htaccess work because of the proxy? or do I need to make certain changes to the nginx config for this?

I suppose I need to uncomment:
Code:
        #location ~ /\.ht {
        #    deny  all;


Question 5: Does nginx basic lack other functions except lua support?


4: http://stackoverflow.com/questions/8711678/change-apache-htaccess-file-to-be-used-with-nginx

5: See the feature list, we've marked features without a * for the full version.


Last edited by ng4win on Mon 02 Jun '14 14:32; edited 1 time in total
Back to top
Qmpeltaty



Joined: 06 Feb 2008
Posts: 182
Location: Poland

PostPosted: Mon 02 Jun '14 10:50    Post subject: Reply with quote

I have a question from the networking side - how could ng4win manage to serve a 1milion connections when TCP allows only for ~65k ports to be opened per IP ??
Back to top
ng4win



Joined: 25 May 2014
Posts: 78

PostPosted: Mon 02 Jun '14 11:26    Post subject: Reply with quote

Qmpeltaty wrote:
I have a question from the networking side - how could ng4win manage to serve a 1milion connections when TCP allows only for ~65k ports to be opened per IP ??


To keep it simple: http://stackoverflow.com/questions/2332741/what-is-the-theoretical-maximum-number-of-open-tcp-connections-that-a-modern-lin

Windows is no different.
Back to top
gijs



Joined: 27 Apr 2012
Posts: 189
Location: The Netherlands

PostPosted: Mon 02 Jun '14 14:50    Post subject: Reply with quote

I have some mod security rules on Apache as well, how should I migrate those?
Back to top
ng4win



Joined: 25 May 2014
Posts: 78

PostPosted: Mon 02 Jun '14 15:59    Post subject: Reply with quote

gijs wrote:
I have some mod security rules on Apache as well, how should I migrate those?

There is only one way and that's to learn how Naxsi works. Afaik there is no conversion tool out there yet.
Back to top
C0nw0nk



Joined: 07 Oct 2013
Posts: 241
Location: United Kingdom, London

PostPosted: Mon 02 Jun '14 16:13    Post subject: Reply with quote

To be honnest you do not even need mod security if you sit behind a service like CloudFlare.com (Like i do) but then i don't know what your application is it could be old outdated and realy insecure.

I run Joomla 2.5.x

Also i will add even Cloudflare run Nginx but they run it in a Linux not Windows enviorment. Aswell as CloudFlare now runs most of the entire worlds internet traffic through their network.
Back to top
C0nw0nk



Joined: 07 Oct 2013
Posts: 241
Location: United Kingdom, London

PostPosted: Fri 06 Jun '14 19:07    Post subject: Reply with quote

For me now all my web pages with dynamic php/mysql content from Joomla all load in less than 1 second about 0.6 to be more accurate.

Nginx is very fast at delievering static content and for my php via fastcgi i found the bottle neck to it was my 32bit mysql server. I made it all 64bit and now it flys like a bullet.

ng4win with your nginx version do you plan on releasing or compiling a 64bit version ?
Back to top
gijs



Joined: 27 Apr 2012
Posts: 189
Location: The Netherlands

PostPosted: Fri 06 Jun '14 19:54    Post subject: Reply with quote

Do you use fastcgi in Nginx or Apache?
If you're using it in Nginx, did you notice a speed improvement over Apache?
Back to top
C0nw0nk



Joined: 07 Oct 2013
Posts: 241
Location: United Kingdom, London

PostPosted: Fri 06 Jun '14 20:47    Post subject: Reply with quote

gijs wrote:
Do you use fastcgi in Nginx or Apache?
If you're using it in Nginx, did you notice a speed improvement over Apache?


Using fastcgi is the same speed as proxying to apache the only difference will be noticable by a few mili seconds because of when you proxy to apache, apache then has to read and deal with the request and then pass it to php.

Cutting out the apache middle man makes it only a few mili seconds faster.

I use apache with mod_fcgi. But if you realy care about a few miliseconds just drop apache and use fastcgi on nginx.

For me having a high traffic site in the alexa top 30,000 sites and every page loads in less than 1 second with mysql, php and nginx i am happy enough also my cpu stays around 0-5% all the time.

Aswell as if you cut out apache in the middle i suppose you will not be limited by the max traffic apache can handle thread wise.

If i am correct in my understanding from the apache winnt_mpm

we are limited to this number
Code:
<IfModule mpm_winnt_module>
ThreadsPerChild 1920
MaxConnectionsPerChild   0
</IfModule>


So we can only handle on apache almost 2000 connections with windows but with nginx we can handle a million. So depending on your forms of traffic and what you require i recommend nginx as a better soloution for high traffic sites.

I require media streaming what means every time a connection has to stay open so someone can download a file that can take a few mins each and when you have thousands of people all downloading/connecting at the same time that exhausts all your connections
Back to top
ng4win



Joined: 25 May 2014
Posts: 78

PostPosted: Fri 06 Jun '14 23:44    Post subject: Reply with quote

C0nw0nk wrote:
ng4win with your nginx version do you plan on releasing or compiling a 64bit version ?

When all the base code and add-ons code is written for 64bit mode then yes, otherwise it will make no difference, ea. 32bit code will keep doing 32bit things, a 64bit compile might even slow things down.
Back to top
C0nw0nk



Joined: 07 Oct 2013
Posts: 241
Location: United Kingdom, London

PostPosted: Sat 07 Jun '14 7:59    Post subject: Reply with quote

I was only asking because i went from a 32bit to a 64bit mysql server and my cpu usage went down and my site speeds improved amazingly use to take 1-3 seconds per each page load now it does it in a few miliseconds.

Was curious if a 64bit would of been any faster than a 32bit nginx and if it would be more powerfull.
Back to top
ng4win



Joined: 25 May 2014
Posts: 78

PostPosted: Sat 07 Jun '14 13:32    Post subject: Reply with quote

C0nw0nk wrote:
I was only asking because i went from a 32bit to a 64bit mysql server and my cpu usage went down and my site speeds improved amazingly use to take 1-3 seconds per each page load now it does it in a few miliseconds.

Was curious if a 64bit would of been any faster than a 32bit nginx and if it would be more powerfull.

It would be interesting to see if there are any my.ini differences, but then again the 64bit version most likely contains real 64bit code. I'll have a look what a 64bit compile does.
Back to top
C0nw0nk



Joined: 07 Oct 2013
Posts: 241
Location: United Kingdom, London

PostPosted: Sat 07 Jun '14 18:48    Post subject: Reply with quote

Thanks ng4win looking forward to the results.

I can share my mysql config if you like.
I always was curious why my site seems so slow but yet php, apache, nginx was all delievering as soon as the request to the server was sent. The bottle neck of my applications turned out to be a 32bit mysql server.

I downloaded the mysql installer http://dev.mysql.com/downloads/installer/5.6.html

And set it up for a dedicated machine without any of the development components (All production) and it flys like a bullet now, So for anyone else who uses 32bit mysql in a 64bit enviorment i recommend you make a switch. (You will have to setup databases and phpmyadmin etc yourself but it is worth it, Something anyone serious about hosting or running a decent website should do.)
Back to top
ng4win



Joined: 25 May 2014
Posts: 78

PostPosted: Sat 07 Jun '14 19:12    Post subject: Reply with quote

C0nw0nk wrote:
I can share my mysql config if you like.


Have a look at a typical 32bit tuned environment which does fly (relevant parts):

[mysqld]
skip-external-locking
key_buffer_size = 128M
max_allowed_packet = 16M
table_open_cache = 64
sort_buffer_size = 2M
net_buffer_length = 8K
read_buffer_size = 2M
join_buffer_size = 2M
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 64M
table_cache=512
max_heap_table_size=256M
tmp_table_size=128M
thread_cache=256
query_cache_type=1
query_cache_limit=4M
query_cache_size=64M
thread_concurrency=2
delay_key_write=on
wait_timeout=28800
interactive_timeout=28800
max_connections = 2000
max_user_connections = 250

[isamchk]
key_buffer=128M
sort_buffer_size=128M
read_buffer=2M
write_buffer=2M

[myisamchk]
key_buffer_size = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M

Maybe you can spot what is different with your 64bit settings.
Back to top


Reply to topic   Topic: Nginx vs Other Webservers on WINDOWS ONLY View previous topic :: View next topic
Post new topic   Forum Index -> Apache Page Previous  1, 2, 3, 4, 5, 6  Next