방금 한 사이트에서 정적 요청을 처리하도록 nginx를 설정했지만 서버에 많은 사이트가 있으며 궁금합니다. 그들 모두를위한 nginx 서버 구성? 내가 지금 뭐하고있는거야.올바른 방법으로 모든 가상 호스트를 제공하는 nginx의 Apache 및 궁극적 인 구성
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>
나는 아파치의 ports.conf이 있습니다 :
Listen 8080
그래서 내가 작업의 nginx를 설정 한 나는이 같은 일부-것으로, 아파치에 대한 모든 가상 호스트 항목과 파일이 하나 개의 사이트에서 (sky2high.net), 생성 된 다음 구성 파일 (/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;
}
}
그리고이 도메인에 대해 잘 작동하지만 물론 다른 가상 호스트는 부서진.
그래서, 질문 : nginx에 대한 궁극적 인 구성 옵션이 있습니까, 마녀가 모든 가상 호스트 (도메인)에서 모든 요청을 처리하고 올바른 방식으로 그들을 제공하는 데 도움이 될 수 있습니까? 내 말은, 각 가상 호스트에 대해 separete 구성 파일을 작성하지 못하게하는 옵션 (루트 및 색인 옵션과 같이 두 배로 된이 모든 항목 포함)이지만 모든 가상 호스트에 대해 하나뿐입니다.
추신 : serverfault로 질문을 이동해야합니까?
업데이트 : Emm 나는 그것이 어떻게 작동하는지 궁금하지만, 그렇습니다. 나는 다음 설정 파일을했습니다 :
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/*;
}
및
을/etc/nginx를/사이트 사용/기본
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
/etc/nginx/nginx.conf 그것이 어떻게 작동하는지 이해가 안되지만 ...업데이트 2 : 또는 작동하지 않습니다! 나는 콘솔에서 "top"을 보았고 apache가 PHP 요청뿐만 아니라 정적 콘텐츠도 제공한다는 것을 알았습니다. (
변경할 수있는 한 줄에 : proxy_set_header 호스트 $ 호스트 : $의 PROXY_PORT; – dalore