Я пытался настроить среду локально на MacOS, которая позволяет мне добавить новую папку проекта в /var/www/
, она будет принимать имя проекта в качестве имени хоста и передавать его на порт 80, проксированный через порт 5000.
В настоящее время при переходе на localhost в браузере происходит переход на страницу приветствия nginx hello default, но когда я пытаюсь перейти на testsite.local.dev
, я получаю отказ от подключения в браузере ERR_CONNECTION_REFUSED
Вот мойnginx.conf и мои файлы настроек wildcard.conf:
nginx.conf
user <user> staff;
worker_processes 1;
error_log /var/log/nginx.error.log;
error_log /var/log/nginx.error.log notice;
error_log /var/log/nginx.error.log info;
pid /var/tmp/nginx.pid;
events {
worker_connections 128;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"';
#access_log /var/log/nginx.access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
server_name localhost;
#access_log /var/log/nginx.localhost.access.log main;
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_buffers 256 128k;
fastcgi_connect_timeout 300s;
fastcgi_send_timeout 300s;
fastcgi_read_timeout 300s;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
location ~ /\.ht {
deny all;
}
}
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
include /usr/local/etc/nginx/sites-available/*.conf;
}
wildcard.conf
server {
listen 80;
server_name ~^(?<sname>.+)$;
root /var/www/$sname/html/;
index index.html index.htm index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
proxy_pass http://127.0.0.1:5000;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log /var/log/nginx/$sname-access.log;
error_page 404 /index.php;
sendfile off;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}