У меня есть неуправляемый VPS под управлением Centos7, у меня есть несколько доменов (с внешним регистратором, каждый из которых в конечном итоге будет работать с nodejs + mongo или django), которые я хочу запустить с сервера.
Я изначальноустановлен MaraDNS для обработки DNS, который работал нормально (например, iwantscones.uk ). Но тогда мне порекомендовали установить nginx на сервер.
Nginx является новым для меня, я установил его, и он, кажется, работает правильно, и домены попадают на веб-сервер, но когда nginx запускается, внешнийдомены больше не разрешаются в соответствующие каталоги. Я предполагаю, что nginx переопределяет настройки MaraDNS и что мне нужно снова настроить сопоставление каталогов в среде nginx, но не могу найти четких инструкций для этого - и единственные четкие инструкции относятся к настройкам, использующим sites-available
, который нечасть установки CentOS7.
Когда nginx включен, я получаю «404 Not Found» в домене, но он, безусловно, попадает на правильный веб-сервер, потому что «nginx / 1.17.4» указано ниже.
Я попытался скопировать тестовые файлы по указанному ниже пути к папке, но они не отображаются, поэтому я предполагаю, что nginx DNS настроен неправильно, но я пытаюсь найти полезное направление:
home/nginx/iwantscones.uk/public_html
Любойдобро пожаловать, извиняюсь за вопросы новичка.
Я добавил файлы конфигурации varios ниже для ясности:
/ etc / nginx / nginx.conf:
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/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;
index index.html index.html
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/domains/*.conf;
}
/ etc / nginx / domains / default.conf
server {
listen 80;
server_name 127.0.0.1;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
root /usr/share/nginx;
location / {
}
#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 /usr/share/nginx/html;
}
include /etc/nginx/conf.d/block.conf;
}
/ etc / nginx / domains / iwantscones.uk.conf
upstream node_nginx {
ip_hash;
server 127.0.0.1:8000;
}
server {
listen 80;
server_name www.iwantscones.uk iwantscones.uk;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
error_log /home/nginx/iwantscones.uk/log/error.log error;
root /home/nginx/iwantscones.uk/public_html;
location / {
proxy_read_timeout 1800;
proxy_connect_timeout 1800;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
# prevents 502 bad gateway error
proxy_buffers 8 32k;
proxy_buffer_size 64k;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_pass http://iwantscones.uk/ ;
proxy_redirect off;
}
#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 /home/nginx/iwantscones.uk/public_html;
}
include /etc/nginx/conf.d/block.conf;
}
/ etc / nginx / conf.d /block.conf
location = /robots.txt { access_log off; log_not_found off; }
location = /favicon.ico { access_log off; log_not_found off; expires 30d; }
location ~ /\. { access_log off; log_not_found off; deny all; }
location ~ ~$ { access_log off; log_not_found off; deny all; }
location ~ /\.git { access_log off; log_not_found off; deny all; }
location = /nginx.conf { access_log off; log_not_found off; deny all; }
/ etc / nginx / conf.d / default.conf
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
#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 /usr/share/nginx/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 html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$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;
#}
}