我目前正在将我们的HTTP网站重定向到HTTPS版本。我正在Windows 10服务器上使用NGINX,并已成功安装。然而,我遇到了一个问题,我似乎无法找到正确的网站。我怀疑我的配置文件可能有问题。我一直得到“欢迎来到nginx!“页面而不是预期的网页。将端口8080添加到DNS名称可以工作,但我们希望使用正确的DNS访问页面而不指定端口。
Config文件看起来像默认文件,但添加了以下行(不确定是否正确):
http {
include mime.types;
include "C:/SkySpark/var/etc/nginx-1.25.2/nginx-1.25.2/conf/*.conf"
include "C:/SkySpark/var/etc/nginx-1.25.2/nginx-1.25.2/sites-enabled/*"
default_type application/octet-stream;
然后我创建了一个名为enabled-sites的新文件夹,其中包含指向文件skyspark.config的符号链接:
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name sky****.com;
#Redirect all HTTP requests to HTTPS with a 301 Moved Permanently response
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name sky****.com;
set_real_ip_from 127.0.0.1;
real_ip_header X-Real-IP;
real_ip_recursive on;
#SkySpark Cluster traffic
location /cluster/ {
proxy_pass http://127.0.0.1:8080;
#IMPORTANT - proxy_pass directive MUST NOT have a trailing /
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
#Browser SkySpark traffic
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto http;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
ssl_certificate ****;
ssl_certificate_key ****;
ssl_session_timeout 10m;
ssl_session_cache shared:SSL:10m;
ssl_session_tickets off;
ssl_protocols TLSv1.3 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers ECDH+AESGCM:ECDH+AES256:ECDH+AES128:DHE+AES128:!aNULL:!eNULL:!LOW;
gzip on;
gzip_types text/plain;
gzip_proxied no-cache no-store private expired auth;
gzip_min_length 1000;
}
我想是因为那些包含线...如果有人有想法,请让我知道!
1条答案
按热度按时间b4lqfgs41#
无论如何,这些是我的想法:
通常你不必自己添加包含行。
sites-enabled
文件夹应该已经创建好了,你只需要把你的配置文件放在sites-enabled
文件夹中,而不必编辑根配置文件。Nginx应该自己找到每个配置文件。