Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3228092
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:39:05+00:00 2026-05-17T16:39:05+00:00

I’ve just set up nginx to serve static request on one site, but I

  • 0

I’ve just set up nginx to serve static request on one site, but I have lots of sites on my server and I wonder, should I right new nginx server configuration for all of them?
What I’m doing now. I have file with all virtual hosts entries for Apache with some-thing like this:

NameVirtualHost *:8080
<VirtualHost *:8080>
 ServerName sky2high.net
 DocumentRoot /home/mainsiter/data/www/sky2high.net
</VirtualHost>

<VirtualHost *:8080>
 ServerName surdo.asmon.ru
 DocumentRoot /home/surdo/data/www/surdo.asmon.ru
</VirtualHost>

<VirtualHost *:8080>
 ServerName surdoserver.ru
 DocumentRoot /home/surdo/data/www/surdoserver.ru
</VirtualHost>

I have this in apache’s ports.conf:

Listen 8080

And so I’ve set up nginx to work with one site (sky2high.net), created next configure file (/etc/nginx/sites-enabled/sky2high.net):

server {
 listen 80;
 server_name sky2high.net www.sky2high.net;
  proxy_pass http://127.0.0.1:8000;
   proxy_set_header Host $host;

 access_log /var/log/nginx.access_log;

 location ~* \.(jpg|jpeg|gif|png|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|tar|wav|bmp|rtf|swf|ico|flv|txt|xml|docx|xlsx)$ {
  root /home/mainsiter/data/www/sky2high.net/;
  index index.php;
  access_log off;
  expires 30d;
 }
 location ~ /\.ht {
  deny all;
 }
 location / {
  proxy_pass http://127.0.0.1:8080/;
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header X-Forwarded-for $remote_addr;
  proxy_set_header Host $host;
  proxy_connect_timeout 60;
  proxy_send_timeout 90;
  proxy_read_timeout 90;
  proxy_redirect off;
  proxy_set_header Connection close;
  proxy_pass_header Content-Type;
  proxy_pass_header Content-Disposition;
  proxy_pass_header Content-Length;
 }
} 

And it works fine for this domain, but of course another virtual hosts are broken.

So, the question is: is there ultimate config option for nginx, witch can help to handle all request, from all virtual hosts (domains) and serve them in the right way? I mean, option that allows not to write separete configure files for each virtual hosts (with all this doubled stuff like root and index options), but only one for all virtual hosts?

PS: should I move question to serverfault?

UPDATE:
Emm.. I wonder how is it works, but it is. I’ve made next config files:

/etc/nginx/nginx.conf

user www-data;
worker_processes  2;

error_log  /var/log/nginx/error.log;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    access_log  /var/log/nginx/access.log;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;
    tcp_nodelay        on;

    gzip             on;   
    gzip_min_length  1000;
    gzip_proxied     any;
    gzip_disable     "msie6";

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}

and

/etc/nginx/sites-enabled/default

server {
    listen 80;

    location / {
        proxy_pass http://127.0.0.1:8080/;
        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;
        proxy_set_header Connection close;
        proxy_pass_header Content-Type;
        proxy_pass_header Content-Disposition;
        proxy_pass_header Content-Length;
    }
}

I do not understand how is it works, but it is…

UPDATE 2: or it doesn’t work! I’ve looked to “top” in console and metioned that apache serves not only php request, but for static content either =(

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T16:39:06+00:00Added an answer on May 17, 2026 at 4:39 pm

    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

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I have a JSP page retrieving data and when single or double quotes are
I'm looking for suggestions for debugging... If you view this site in Firefox or
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
this is what i have right now Drawing an RSS feed into the php,
I want use html5's new tag to play a wav file (currently only supported
I've got a string that has curly quotes in it. I'd like to replace
For some reason, after submitting a string like this Jack’s Spindle from a text
Does anyone know how can I replace this 2 symbol below from the string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.