已将nginx安装到centos7 VPS,但DNS中断
我有一个运行Centos7的非托管VPS,我有多个域(带有外部注册器,每个域最终将运行nodejs+mongo或django),我希望从服务器上运行这些域 我最初安装的目的是处理DNS,它工作得很好(例如)。但后来有人建议我在服务器上安装nginx Nginx对我来说是新的,我已经安装了它,它似乎运行正常,域正在访问web服务器,但是当Nginx启动时,外部域不再解析到适当的目录。我假设nginx正在覆盖MaraDNS的设置,我需要在nginx环境中再次设置到目录的映射,但找不到明确的说明-唯一明确的说明是使用可用的已将nginx安装到centos7 VPS,但DNS中断,nginx,dns,centos7,vps,nginx-config,Nginx,Dns,Centos7,Vps,Nginx Config,我有一个运行Centos7的非托管VPS,我有多个域(带有外部注册器,每个域最终将运行nodejs+mongo或django),我希望从服务器上运行这些域 我最初安装的目的是处理DNS,它工作得很好(例如)。但后来有人建议我在服务器上安装nginx Nginx对我来说是新的,我已经安装了它,它似乎运行正常,域正在访问web服务器,但是当Nginx启动时,外部域不再解析到适当的目录。我假设nginx正在覆盖MaraDNS的设置,我需要在nginx环境中再次设置到目录的映射,但找不到明确的说明-唯一
站点进行设置
,这不是CentOS7安装的一部分
当启用nginx时,我在域上得到一个“404未找到”,但它肯定会命中正确的web服务器,因为下面说明了“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;
}
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;
#}
}
/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 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;
}
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;
#}
}
嘿,里奇。我认为这与您的DNS配置无关。DNS似乎击中了您的Web服务器,这就是它应该做的一切。将域解析为IP,而不是位置。所以这应该很好。您能发布完整的nginx和
server{}
block吗?非常感谢@Raul,我已经添加了各种conf文件/server{}块-希望这些是正确的。