У меня есть сервер nginx/node.js, который я пытаюсь настроить. В основном это проблема одновременного запуска 2 веб-серверов на порту 80. У меня есть www.mysite.com, что мне нужно указать на nginx на порт 80. Но у меня также есть сервер node.js, который мне нужен api.mysite.com, чтобы указать на порт 8888.Получение nginx и node.js для игры nice
Я возился с proxy_pass в моей конфигурации (http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass), но не повезло. Я также пробовал это https://stackoverflow.com/a/20716524/605841 без везения.
Если у кого есть какие-либо советы, которые были бы замечательными. Заранее спасибо.
Nginx public dir:/var/www/html. Экспресс приложение местоположение:/вар/WWW/HTML/myNodeAppRoot
Вот мой /etc/nginx/sites-available/api.mysite.com файл (SYM связан в сайты с поддержкой):
server {
listen 80;
# server_name ~^(?<login>[a-z]+)\.api\.mysite\.com$;
server_name api.mysite.com$;
location/{
# root /var/www/html/myNodeAppRoot;
# proxy_pass http://unix:/tmp/\$login.api.mysite.com.sock:$uri$is_args$args;
proxy_pass http://unix:/tmp/api.mysite.com.sock:$uri$is_args$args;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
А вот мой default.conf файл:
#
# The default server
#
server {
listen 80 default_server;
server_name www.mysite.com;
#charset koi8-r;
#access_log logs/host.access.log main;
location/{
root /var/www/html;
index index.php index.html index.htm;
}
error_page 404 /404.html;
location = /404.html {
root /var/www/html;
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root /var/www/html;
try_files $uri =404;
# fastcgi_pass 127.0.0.1:9000;
fastcgi_pass unix:/tmp/php5-fpm.sock;
fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
Спасибо за любую помощь!