내 서버에 여러 계정/도메인이 있습니다. 나 아파치 2.4와 cPanel을 사용하고 프론트 리버스 프록시로 Nginx를 사용하고 싶었어요. 내가 아파치 포트를 변경 Nginx를 설치하고 그것은 잘 작동 하나의 도메인/계정. 나는 서버의 모든 도메인과 앞으로의 모든 계정에 사용하고 싶습니다. 특정 도메인 대신 변수 $domain
을 입력하려고했지만 나중에 nginx가 변수를 지원하지 않는다는 것을 깨달았습니다. 사용자 디렉토리의 경우와 동일합니다. 내가 할 노력하고있어여러 도메인에 대한 Nginx 역방향 프록시 구성
user nobody;
worker_processes 4;
error_log logs/error.log crit;
worker_rlimit_nofile 8192;
events {
worker_connections 1024; # you might need to increase this setting for busy servers
use epoll; # Linux kernels 2.6.x change to epoll
}
http {
server_names_hash_max_size 2048;
server_names_hash_bucket_size 512;
server_tokens off;
include mime.types;
default_type application/octet-stream;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 10;
# Gzip on
gzip on;
gzip_min_length 1100;
gzip_buffers 4 32k;
gzip_types text/plain application/x-javascript text/xml text/css;
# Other configurations
ignore_invalid_headers on;
client_max_body_size 8m;
client_header_timeout 3m;
client_body_timeout 3m;
send_timeout 3m;
connection_pool_size 256;
client_header_buffer_size 4k;
large_client_header_buffers 4 32k;
request_pool_size 4k;
output_buffers 4 32k;
postpone_output 1460;
# Cache most accessed static files
open_file_cache max=10000 inactive=10m;
open_file_cache_valid 2m;
open_file_cache_min_uses 1;
open_file_cache_errors on;
# virtual hosts includes
include "/etc/nginx/conf.d/*.conf";
server {
# this is your access logs location
access_log /usr/local/apache/domlogs/accountusername/example.com;
error_log logs/vhost-error_log warn;
listen 80;
# change to your domain
server_name example.com www.example.com;
location ~* \.(gif|jpg|jpeg|png|wmv|avi|mpg|mpeg|mp4|htm|html|js|css)$ {
# this is your public_html directory
root /home/accountusername/public_html;
}
location/{
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 16 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
proxy_connect_timeout 30s;
# change to your domain name
proxy_redirect http://www.example.com:8080 http://www.example.com;
proxy_redirect http://example.com:8080 http://example.com;
proxy_pass http://127.0.0.1:8080/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
}
는 서버에있는 모든 도메인과 추가됩니다 향후 도메인에 대해 작동하는 코드를 삽입하는 것입니다 : 여기 내 설정 파일입니다. 일부 포럼과 블로그에서 가상 호스트 설정 (서버 블록)에 대해 설명하지만 실제로 어떤 용도로 사용되는지는 잘 모르겠습니다. 만약 누군가가 이것에 대해 어떤 정보라도 제공한다면 나는 그것을 고맙게 생각할 것입니다. 가상 호스트를 설정해야합니까? 구성 파일에서 무엇을 변경해야합니까? 고맙습니다.
매우 도움이 파비콘이 표시되지 않습니다 왜 그렇게 : 당신은 알고 계십니까 감사? 코드 행이 누락 된 것일까 요? –
**이 코드는 ** server {} **'location =/favicon.ico {log_not_found off; access_log off;}'에서 사용했지만 작동하지 않았습니다. –
올바른 위치입니다. 'log_not_found off'를 제거하고 nginx 파일을 찾을 수없는 error_log를 확인하십시오. –