Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nginx serving static content and proxy to apache

Tags:

nginx

apache

Is there a configuration I can use with nginx that would serve all static content for all wbsites on port 80 and all dynamic content would be forwarded to apache on port 8080? Preferably I would like to not have to change anything in apache vhosts other than port

Where can I find such working configuration?

like image 516
DavidW Avatar asked Jun 17 '11 22:06

DavidW


1 Answers

Here's a good example; http://wiki.nginx.org/FullExample

Special emphasis on this part;

    server { # simple reverse-proxy
    listen       80;
    server_name  domain2.com www.domain2.com;
    access_log   logs/domain2.access.log  main;

    # serve static files
    location ~ ^/(images|javascript|js|css|flash|media|static)/  {
      root    /var/www/virtual/big.server.com/htdocs;
      expires 30d;
    }

    # pass requests for dynamic content to rails/turbogears/zope, et al
    location / {
      proxy_pass      http://127.0.0.1:8080;
    }
  }
like image 160
k_b Avatar answered Sep 29 '22 23:09

k_b