【发布时间】:2019-02-27 07:02:43
【问题描述】:
我正在尝试使用 Let's Encrypt 的 certbot 提供的 ssl 加密在 Centos7 服务器上的 nginx 中设置一个子域(暂时)的网站。
我已经成功安装了 nginx,我已经设置了我的域:example.com www.example.com 和 ci.example.com 并获得了没有任何问题的证书(我的浏览器显示“安全”并且它自动从 http 请求重定向到 https .)
现在我想让ci.example.com 代理到 localhost:6500 端口(@987654326@ 我相信它被调用了)。我试过以下:
this blog post from 2014 但 nginx 一直服务于标准的“欢迎来到 Nginx 页面”。
所有其他文章/教程都是针对旧版本的 nginx(不使用 /etc/nginx/nginx.conf。
这里是/etc/nginx/nginx.conf
http {
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;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
server {
server_name example.com www.example.com;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
server {
if ($host = www.example.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = example.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = ci.example.com) {
return 301 https://$host$request_uri;
} #added by me
listen 80 default_server;
listen [::]:80 default_server;
server_name example.com www.example.com;
return 404; # managed by Certbot
【问题讨论】: