Apache and ultimate config for nginx to serve all virtual hosts in the right way Apache and ultimate config for nginx to serve all virtual hosts in the right way apache apache

Apache and ultimate config for nginx to serve all virtual hosts in the right way


What you do now is sending all the network traffic to 127.0.0.1:8080 without allowing Nginx to serve the static files.

What you should try is the following:

server {listen 80;server_name sky2high.net www.sky2high.net;location / {proxy_pass http://127.0.0.1:8080;include /etc/nginx/conf.d/proxy.conf;}location ~* ^.+\.(jpg|jpeg|gif|png|ico|tgz|gz|pdf|rar|bz2|exe|ppt|txt|tar|mid|midi|wav|bmp|rtf) {root /folder/to/static/files;expires 90d;}location ~* ^.+\.(css|js)$ {root /folder/to/static/files;expires 30d;}

And in proxy.conf you put the following:

proxy_redirect off;proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;client_max_body_size 8m;client_body_buffer_size 256k;proxy_connect_timeout 60;proxy_send_timeout 60;proxy_read_timeout 60;proxy_buffer_size 4k;proxy_buffers 32 256k;proxy_busy_buffers_size 512k;proxy_temp_file_write_size 256k;

This should work for you


Just my two cents, in most cases it's not necessary to specify the listen 80.

Source: Nginx common Pitfalls