Answer the question
In order to leave comments, you need to log in
Why can't NodeJS (request) make a request to a local resource by domain?
There is a server machine on Debian 8.6 x64.
Literally yesterday they installed it, everything was set up, it costs ISPManager, Apache2 (: 8080) + Nginx (: 80), NodeJS (v4.6.2, but I tried different ones, from 0.12 to 7.1). For requests, the Request
package is used .
Request via domain:
request('https://my-domain.ru/rest/request', callback());
[Error: getaddrinfo ENOTFOUND my-domain.ru my-domain.ru:443]
code: 'ENOTFOUND',
errno: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: 'my-domain.ru',
host: 'my-domain.ru',
port: 443 }
request('http://175.90.1.55', callback());
server {
server_name my-domain.ru www.my-domain.ru;
charset UTF-8;
index index.html index.php;
disable_symlinks if_not_owner from=$root_path;
include /etc/nginx/vhosts-includes/*.conf;
include /etc/nginx/vhosts-resources/my-domain.ru/*.conf;
access_log /var/www/httpd-logs/my-domain.ru.access.log;
error_log /var/www/httpd-logs/my-domain.ru.error.log notice;
set $root_path /var/www/domain_user/data/www/my-domain.ru/public;
root $root_path;
location / {
location ~ [^/]\.ph(p\d*|tml)$ {
try_files /does_not_exists @fallback;
}
location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
try_files $uri $uri/ @fallback;
}
location / {
try_files /does_not_exists @fallback;
}
}
location @fallback {
proxy_pass http://127.0.0.1:8080;
proxy_redirect http://127.0.0.1:8080 /;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
access_log off;
}
listen 175.90.1.55:80;
return 301 https://$host:443$request_uri;
}
server {
server_name my-domain.ru www.my-domain.ru;
ssl on;
ssl_certificate "/var/www/httpd-cert/domain_user/my-domain.ru.crtca";
ssl_certificate_key "/var/www/httpd-cert/domain_user/my-domain.ru.key";
ssl_ciphers EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH;
ssl_prefer_server_ciphers on;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
add_header Strict-Transport-Security "max-age=31536000;";
charset UTF-8;
index index.html index.php;
disable_symlinks if_not_owner from=$root_path;
include /etc/nginx/vhosts-includes/*.conf;
include /etc/nginx/vhosts-resources/my-domain.ru/*.conf;
access_log /var/www/httpd-logs/my-domain.ru.access.log;
error_log /var/www/httpd-logs/my-domain.ru.error.log notice;
set $root_path /var/www/domain_user/data/www/my-domain.ru/public;
root $root_path;
location / {
location ~ [^/]\.ph(p\d*|tml)$ {
try_files /does_not_exists @fallback;
}
location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
try_files $uri $uri/ @fallback;
}
location / {
try_files /does_not_exists @fallback;
}
}
location @fallback {
proxy_pass http://127.0.0.1:8080;
proxy_redirect http://127.0.0.1:8080 /;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-<code>P</code>roto $scheme;
access_log off;
}
listen 175.90.1.55:443;
}
<VirtualHost 127.0.0.1:8080>
ServerName my-domain.ru
DocumentRoot /var/www/domain_user/data/www/my-domain.ru/public
ServerAdmin [email protected]
AddDefaultCharset UTF-8
AssignUserID domain_user domain_user
CustomLog /var/www/httpd-logs/my-domain.ru.access.log combined
ErrorLog /var/www/httpd-logs/my-domain.ru.error.log
<FilesMatch "\.ph(p[3-5]?|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
php_admin_value sendmail_path "/usr/sbin/sendmail -t -i -f [email protected]"
php_admin_value upload_tmp_dir "/var/www/domain_user/data/mod-tmp"
php_admin_value session.save_path "/var/www/domain_user/data/mod-tmp"
php_admin_value open_basedir "/var/www/domain_user/data:."
ServerAlias www.my-domain.ru
DirectoryIndex index.html index.php
</VirtualHost>
<Directory /var/www/domain_user/data/www/my-domain.ru>
Options -ExecCGI
php_admin_flag engine on
</Directory>
Answer the question
In order to leave comments, you need to log in
Tell me, do you get the desired result using https://my-domain.ru/rest/request through a browser?
I don't want to offend anyone, with such a set of tools you look like a knowledgeable person, but is the virtual host my-domain.ru exactly configured correctly? ;-)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question