Search Results

Search found 6 results on 1 pages for 'garreth mcdaid'.

Page 1/1 | 1 

  • Varnish server in front of nginx server with multiple virtualhosts

    - by Garreth 00
    I have tried to search for a solution for this, but can't find any documentation/tips on my specific setup. My setup: Backendserver: ngnix: 2 different websites (2 top domains) in virtualenv, running gunicorn/python/django Backendserver hardware(VPS) 2gb ram, 8 CPU Databaseserver: postgresql - pg_bouncer Backendserver hardware (VPS) 1gb ram, 8 CPU Varnishserver: only running varnish Varnishserver hardware (VPS) 1gb ram, 8 CPU I'm trying to set up a varnish server to handle rare spike in traffic (20 000 unique req/s) The spike happens when a tv program mention one of the sites. What do I need to do, to make the varnish server cache both sites/domains on my backendserver? My /etc/varnish/default.vcl : backend django_backend { .host = "local.backendserver.com"; .port = "8080"; } My /usr/local/nginx/site-avaible/domain1.com upstream gunicorn_domain1 { server unix:/home/<USER>/.virtualenvs/<DOMAIN1>/<APP1>/run/gunicorn.sock fail_timeout=0; } server { listen 80; listen 8080; server_name domain1.com; rewrite ^ http://www.domains.com$request_uri? permanent; } server { listen 80 default_server; listen 8080; client_max_body_size 4G; server_name www.domain1.com; keepalive_timeout 5; # path for static files root /home/<USER>/<APP>-media/; location / { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; if (!-f $request_filename) { proxy_pass http://gunicorn_domain1; break; } } } My /usr/local/nginx/site-avaible/domain2.com upstream gunicorn_domain2 { server unix:/home/<USER>/.virtualenvs/<DOMAIN2>/<APP2>/run/gunicorn.sock fail_timeout=0; } server { listen 80; listen 8080; server_name domain2.com; rewrite ^ http://www.domains.com$request_uri? permanent; } server { listen 80; listen 8080; client_max_body_size 4G; server_name www.domain2.com; keepalive_timeout 5; # path for static files root /home/<USER>/<APP>-media/; location / { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; if (!-f $request_filename) { proxy_pass http://gunicorn_domain2; break; } } } Right now, If I try the Ip of the varnishserver I only get served domain1.com. Would everything be correct if I change the DNS of the two domain to point to the varnishserver, or is there extra setup before it would work? Question 2: Do I need a dedicated server for varnish, or could I just install varnish on my backendserver, or would the server run out of memory quick?

    Read the article

  • Use Match in sshd_config to detect SCP connection

    - by Garreth McDaid
    I use the following directive in sshd_config to detect if the user trying to login to a server is called developer, and issue a bash script to the user if that is the case: Match User developer ForceCommand /bin/dev_login However, when the user tries to upload a file using SCP, they can't, as the dev_login script is interrupting the process. Is it possible to use the Match directive to detect if the connection is SCP rather than a request to open a shell?

    Read the article

  • How to make a correct if-statement to filter out values from a xml-file

    - by Garreth 00
    Edit 3: As requested, I'm trying to simplify my question. Here is a sample of some of my data from a xml file: <entry> <title>Entry 1</title> <f:max_value_a>499 999</f:max_value_a> <f:max_value_b>999 999</f:max_value_b> <f:min_value_a>0</f:min_value_a> <f:min_value_b>500 000</f:min_value_b> <f:min_value_c>1 000 000</f:min_value_c> <f:value_for_a>5,10</f:value_for_a> <f:value_for_b>4,50</f:value_for_b> <f:value_for_c>3,90</f:value_for_c> </entry> <entry> <title>Entry 2</title> <f:min_value_a>0</f:min_value_a> <f:value_for_a>4,20</f:value_for_a> </entry> <entry> <title>Entry 3</title> <f:max_value_a>1 999 999</f:max_value_a> <f:min_value_a>100 000</f:min_value_a> <f:min_value_b>2 000 000</f:min_value_b> <f:value_for_a>3,735</f:value_for_a> <f:value_for_b>3,445</f:value_for_b> </entry> f:value_for_d is the highest value, and f:value_for_c is lower than d, and so on. I have a dynamic targetvalue (lets just go with 2 000 000 in this example) I want to get the value where max_value is greater than the targetvalue, but sometimes max_value is not defined and then set to "0". "0" in max_value should mean unlimited "roof". The min_value can not be greater than targetvalue, but sometimes min_value is not defined and then set to "0". "0" min_value should mean a unlimited "floor". I have tried with this code if ($value_for_d > 0 ){ if (($min_value_d <= $targetvalue) xor ($min_value_d == 0)){ if (($max_value_d >= $targetvalue) xor ($max_value_d == 0)){ $query_result = TRUE; $value = $value_for_d; } } }elseif ($value_for_c > 0 ){ if (($min_value_c <= $targetvalue) xor ($min_value_c == 0)){ if (($max_value_c >= $targetvalue) xor ($max_value_c == 0)){ $query_result = TRUE; $value = $value_for_c; } } }elseif ($value_for_b > 0 ){ if (($min_value_b <= $targetvalue) xor ($min_value_b == 0)){ if (($max_value_b >= $targetvalue) xor ($max_value_b == 0)){ $query_result = TRUE; $value = $value_for_b; } } }elseif ($value_for_a > 0 ){ if (($min_value_a <= $targetvalue) xor ($min_value_a == 0)){ if (($max_value_a >= $targetvalue) xor ($max_value_a == 0)){ $query_result = TRUE; $value = $value_for_a; } } } If I run this code with a targetvalue of "2 000 000", I get this result: Entry 1 - 3.9 (correct value is 3.9) Entry 2 - 0 (correct value is 4.2) Entry 3 - 3.445 (correct value is 3.445) If I set the targetvalue to even lower, to 500 000, I get 0 on all my entries.

    Read the article

  • Project Euler (P14): recursion problems

    - by sean mcdaid
    Hi I'm doing the Collatz sequence problem in project Euler (problem 14). My code works with numbers below 100000 but with numbers bigger I get stack over-flow error. Is there a way I can re-factor the code to use tail recursion, or prevent the stack overflow. The code is below: import java.util.*; public class v4 { // use a HashMap to store computed number, and chain size static HashMap<Integer, Integer> hm = new HashMap<Integer, Integer>(); public static void main(String[] args) { hm.put(1, 1); final int CEILING_MAX=Integer.parseInt(args[0]); int len=1; int max_count=1; int max_seed=1; for(int i=2; i<CEILING_MAX; i++) { len = seqCount(i); if(len > max_count) { max_count = len; max_seed = i; } } System.out.println(max_seed+"\t"+max_count); } // find the size of the hailstone sequence for N public static int seqCount(int n) { if(hm.get(n) != null) { return hm.get(n); } if(n ==1) { return 1; } else { int length = 1 + seqCount(nextSeq(n)); hm.put(n, length); return length; } } // Find the next element in the sequence public static int nextSeq(int n) { if(n%2 == 0) { return n/2; } else { return n*3+1; } } }

    Read the article

  • Jasper Reports Crosstab Query

    - by Sean McDaid
    I'm using Jasper Reports/iReports crosstabs to create a matrix of student and results. So for example Jim is doing subjects A, B, C and Sally is doing A, C What I want is something like: Subj-A Subj-B Subj-C Jim P M D Sally D D But as my SQL orders by name then subject I get: Subj-A Subj-B Subj-C Subj-A Subj-C Jim P M D Sally D D As you can see in the above the results are correct but the formatting is woeful. Is there anyway I can generate the reports to use names and subject only once and filling in the values from here? This probably isn't clear.

    Read the article

  • Customising Web-logics default 404 error page

    - by Sean McDaid
    I am running weblogic 9. When I enter an incorrect URL below the application root I redirect 404 request to a customized error page. Eg. http://localhost:7001/myApp/non-existent redirects to my customised error page. Is there a way to do this for all incorrect URLs entered, not necessarily below the application root? Eg. http://localhost:7001/anything_non-existent should redirect to my customized error page, not the web-logic default one? Thanks

    Read the article

1