내 웹 루트 디렉터리 외부에있는 디렉터리/웹 응용 프로그램이 있습니다.별칭이있는 중첩 된 위치
/var/www/site/htdocs/
그리고 외부 응용 프로그램이 위치는 다음과 같습니다 :
이/var/www/apps/coolapp/
내 질문은 내가 www.mysite.com/coolapp/*
처럼 모든 요청/경로를 매핑의 nginx를 구성하는 방법입니다
/var/www/apps/coolapp/
? 예를 들어, www.mysite.com/coolapp/test.php는 서버
/var/www/apps/coolapp/test.php
이어야합니다.
nginx.conf
파일에 포함 된 production.conf
에 alias
지시문을 추가했습니다. .php 파일을 대신 잡는 또 다른 location
이 있기 때문에 .php 파일을 제외한 모든 파일에 문제가 없습니다. 그래서 location
을 alias
으로 중첩시켜 .php 파일을 잡았으나 이제는 nginx가 .php 파일 "404 File Not Found"를 찾을 수 없다는 것을 알려줍니다. 여기 production.conf
현재
server {
listen 80;
listen 443 ssl;
ssl_certificate /blah/blah/blah;
ssl_certificate_key /blah/blah/blah;
ssl_protocols blah blah blah;
ssl_ciphers blahblahblah;
ssl_prefer_server_ciphers blahblah;
access_log /var/log/nginx/www.mysite.com-access.log;
error_log /var/log/nginx/www.mysite.com-error.log error;
server_name mysite.com www.mysite.com;
root /var/www/site/htdocs;
include conf/magento_rewrites.conf;
include conf/magento_security.conf;
include /var/www/site/nginx/*.conf;
#-------CODE IN QUESTION-------
location /coolapp/ {
alias /var/www/apps/coolapp/;
location ~ \.php {
# Copied from "# PHP Handler" below
fastcgi_param MAGE_RUN_CODE default;
fastcgi_param MAGE_RUN_TYPE store;
fastcgi_param HTTPS $fastcgi_https;
rewrite_log on;
# By default, only handle fcgi without caching
include conf/magento_fcgi.conf;
}
}
# PHP handler
location ~ \.php {
## Catch 404s that try_files miss
if (!-e $request_filename) { rewrite//index.php last; }
## Store code is defined in administration > Configuration > Manage Stores
fastcgi_param MAGE_RUN_CODE default;
fastcgi_param MAGE_RUN_TYPE store;
fastcgi_param HTTPS $fastcgi_https;
rewrite_log on;
# By default, only handle fcgi without caching
include conf/magento_fcgi.conf;
}
# 404s are handled by front controller
location @magefc {
rewrite ^(.*) /index.php?$query_string last;
}
# Last path match hands to magento or sets global cache-control
location/{
## Maintenance page overrides front controller
index index.html index.php;
try_files $uri $uri/ @magefc;
expires 24h;
}
}
conf의 모습입니다/magento_fcgi.conf은 다음과 같습니다 : 여기
fastcgi_pass phpfpm;
## Tell the upstream who is making the request
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_redirect off;
# Ensure the admin panels have enough time to complete large requests ie: report generation, product import/export
proxy_read_timeout 1600s;
# Ensure PHP knows when we use HTTPS
fastcgi_param HTTPS $fastcgi_https;
## Fcgi Settings
include fastcgi_params;
fastcgi_connect_timeout 120;
fastcgi_send_timeout 320s;
fastcgi_read_timeout 1600s;
fastcgi_buffer_size 128k;
fastcgi_buffers 512 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors off;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/apps/coolapp$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
# nginx will buffer objects to disk that are too large for the buffers above
fastcgi_temp_path /tmpfs/nginx/tmp 1 2;
#fastcgi_keep_conn on; # NGINX 1.1.14
expires off; ## Do not cache dynamic content
내가
2014/02/28 11:10:17 [error] 9215#0: *933 connect() failed (111: Connection refused) while connecting to upstream, ................. client: x.x.x.x, server: mysite.com, request: "GET /coolapp/test.php HTTP/1.1", upstream: "fastcgi://[::1]:9000", host: "www.mysite.com"
2014/02/28 11:10:17 [error] 9215#0: *933 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: x.x.x.x, server: mysite.com, request: "GET /coolapp/test.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.mysite.com"
2014/02/28 11:11:59 [error] 9220#0: *1193 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: x.x.x.x, server: mysite.com, request: "GET /coolapp/test.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.mysite.com"
사람을합니까에서는 error.log에서 가져온 몇 가지 오류 메시지입니다 내가 뭘 잘못하고 있는지 알아?
'mage_rewrites.conf'에 무엇이 있는지 알 수 없으므로 잘못된 것이 없습니다. – Melvyn
몇 가지 테스트가 끝나면 별칭 지시문을 사용할 때'$ uri'가 업데이트되지 않는 것으로 보입니다 :'$ uri'는 여전히'/ coolapp /'접두사가 붙습니다. 이것은 문서와 모순되기 때문에 버그 일 수 있습니다. 나는 이것이 루트가 어떻게 작동해야 하는지를 확신합니다. – Zenexer