我有一个DigitalOcean Droplet,我试图托管多个服务器。确切地说,我有以下设置:
1.我的个人网站(使用serve托管的React前端)在localhost:5000
2.我的Jekyll博客使用Bundler(命令:bundle exec jeykll serve
)在localhost:4000 / blog /
上托管
3.在localhost:3031
当我使用上面带有curl
的本地主机网址从服务器测试每个网址时,我得到了正确的回复。
我有一个使用namecheap注册的域名,说 abcd.me ,使用cloudflare来管理我的DNS设置。根据他们的说明,我在namecheap上更新了我的设置以使用Cloudflare的名称服务器。
目前为我工作的是什么:
- 我可以https://abcd.me访问我的个人网站
- 我可以通过http:// {droplet-ip}访问我的nodejs项目:3031
我无法实现的目标:
- 访问我的博客https://blog.abcd.me
目前,访问https://blog.abcd.me会再次返回我的个人网站,只需使用前缀为"博客的网址。"。我的nginx配置如下所示:
server {
listen 3030 default_server;
listen [::]:3030 default_server;
server_name {server-ip};
index index.html index.htm index.nginx-debian.html;
location / {
proxy_pass http://localhost:3031;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
server {
listen 80;
listen [::]:80;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name blog.abcd.me www.blog.abcd.me;
location / {
proxy_pass http://localhost:4000/blog/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
server {
listen 80;
listen [::]:80;
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name abcd.me www.abcd.me;
# location / {
# # First attempt to serve request as file, then
# # as directory, then fall back to displaying a 404.
# try_files $uri $uri/ =404;
#}
location / {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# include snippets/fastcgi-php.conf;
#
# # With php7.0-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php7.0-fpm:
# fastcgi_pass unix:/run/php/php7.0-fpm.sock;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/abcd.me/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/abcd.me/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
}
我无法弄清楚我哪里出错了。有人可以帮帮我吗?