nginx – setup as reverse proxy

 

Previously to take down this wordpress site all you needed to do was hold down F5 for about 20 seconds then the site would take about 5 mins to recover.

There were a few factors causing this and quite a few different methods to solving the problem. WordPress itself is run on php / apache, apache has an evasive mod which can block certain IPs depending on the defined abusive behavior (typical DDOS attack). Since i like to run a few websites behind a single IP i looked at fixing the issue closer to the perimeter….

Enter nginx (engine x) as a reverse proxy, the site now typically caches all content and serves it straight out of memory. No longer does mysql / apache kill itself under high load on the backend…

nginx

You will need to create the nginx directories if they dont already exist. Check /var/log/nginx/error.log (default ubuntu) if any issues starting the service.

sudo aptitude install nginx
sudo service nginx start

The following added to http {}
(located in /etc/nginx/nginx.conf)


log_format cache '***$time_local '
'$remote_addr '
'$upstream_cache_status '
'Cache-Control: $upstream_http_cache_control '
'Expires: $upstream_http_expires '
'"$request" ($status) ';
access_log /var/log/nginx/access.log cache;
error_log /var/log/nginx/error.log;
server_names_hash_bucket_size 64;
proxy_cache_path /var/www/nginx_cache levels=1:2
keys_zone=one:10m
max_size=1g inactive=30m;
proxy_temp_path /var/www/nginx_temp;

the following added to location / {}
(located in /etc/nginx/sites-enabled/default)


proxy_pass http://sigtar;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_redirect off;
proxy_buffering on;
proxy_buffer_size 16k;
proxy_buffers 32 16k;
proxy_cache one;
proxy_cache_valid 200 302 304 10m;
proxy_cache_valid 301 1h;
proxy_cache_valid any 1m;
client_body_buffer_size 128k;
proxy_busy_buffers_size 64k;
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_header Set-Cookie;

Note if you have problems with wordpress redirect issues… check this post;

http://tommcfarlin.com/resolving-the-wordpress-multisite-redirect-loop/

Also confirm you have this line in http {}

server_names_hash_bucket_size 64;

Very basic load test, user load time is reasonably consistent as user count increases.
http://loadimpact.com/load-test/sigtar.com-ad07b7870a75c854a935752b0a032c53

load test

20 Replies to “nginx – setup as reverse proxy”

  1. This app means that you can purchase digital items throughout the app and will
    include third-get together ads that may redirect you
    to a third-party web site. However, please be told that the appp additionally aklows you to play using
    virtuazl currency (referred to as “”Bananas”” and “”Tokens””), which could bee acquired by playing
    mini-video games, watching advertisements, or paying with real money.
    We are trying to find a shop hack for each game.

  2. I don’t even know the way I stopped up right here,
    however I assumed this submit was once good. I don’t recognise
    who you are but definitely you’re going to a famous blogger if you happen to are not already.
    Cheers!

  3. First of all you will lose water, which will most likely
    lead to the reduction of the kg that will appear
    on the weight scale. It needs to be properly looked after because without this all the luxuries of life
    are worthless. And, endocrine gland can be kept healthy only by eating healthy and, by exercising regularly.

    And it is so packed with protein that you’ll be able to get
    through even a long day with the energy you need.

  4. There is no better means than the social media as it is something that people use no matter what.

    Most people of SEO companies has a web creator or developer that looks after the site, and issues have occurred before where SEO perform or coding added through the SEO
    company is actually removed by the particular developer
    or custom made. Search engines consider the relevance of your landing page to your website theme
    as very crucial.

  5. Whatever you do the G Shock are tough and will stay with you no matter what kind of sports activities you do.
    Professionals that specialize in this niche can assist owners with
    developing marketing plans that embrace a variety of online marketing
    strategies to expand their online footprint. Three important
    factors for success of TQM in emergency services: 1.

  6. Spot on with this write-up, I really believe this amazing
    site needs far more attention. I’ll probably be back again to read through more, thanks for the
    advice!

  7. Remember that quitting will always be a process, and it doesn’t usually happen over night.
    The atomizer is basically a filiment which burns the e liquid and changes it to vapor.

    Start small with a purchase at the one month mark and go big with a vacafion at
    the one year mark.

  8. You actually make it appear really easy with your presentation but I find this matter to be actually something
    which I believe I would by no means understand. It sort of feels too complicated and very extensive for me.

    I am looking forward in your subsequent submit, I’ll try to get the hold
    of it!

Leave a Reply

Your email address will not be published.