我有一个网站,在以下示例中,我将所有流量都强制为https 443。 我最近还在端口8890上运行的同一台服务器上安装了一个应用程序。我希望使该应用程序的subdoman可以在sub.example.com上访问,而不是http://ipaddress:8890 当我尝试添加新部分时,无法访问该网站
server {
listen 80;
listen [::]:80;
server_name www.example.com example.com;
rewrite ^ https://example.com$request_uri? permanent;
}
server {
listen 80;
server_name sub.example.com;
location / {
proxy_pass http://private_ip_address:8890;
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 443;
listen [::]:443 ssl http2;
include /usr/local/nginx/conf/openssl.conf;
server_name www.example.com;
rewrite ^ https://example.com$request_uri? permanent;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name example.com;
include /usr/local/nginx/conf/openssl.conf;
root /home/site/public_html;
set $no_cache 0;
index index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
expires 7d;
}
include /usr/local/nginx/conf/wordpress.conf;
include /usr/local/nginx/apps/pagespeed/optimize.conf;
include /usr/local/nginx/conf/cache.conf;
location ~ .php$ {
include /usr/local/nginx/conf/php.conf;
include /usr/local/nginx/conf/fastcgi_params;
}
}