DavidW
DavidW

Reputation: 5129

Nginx serving static content and proxy to 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?

Upvotes: 11

Views: 10176

Answers (1)

k_b
k_b

Reputation: 2480

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;
    }
  }

Upvotes: 19

Related Questions