我已经在 80 上运行我的网站,并想打开另一个端口 8080,但当我输入“https://papa.fit:8080“。
服务器块爸爸健身
server {
listen 80;
listen [::]:80;
server_name papa.fit www.papa.fit;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
root /var/www/waev.in;
# Add index.php to the list if you are using PHP
index index.html index.php index.htm index.nginx-debian.html;
server_name papa.fit www.papa.fit;
include snippets/ssl-papa.fit.conf;
include snippets/ssl-params.conf;
#set client body size to 2M#
# client max body size 2M;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
# 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;
}
location /phpmyadmin {
root /usr/share/;
index index.php index.html index.htm;
location ~ ^/phpmyadmin/(.+\.php)$ {
try_files $uri =404;
root /usr/share/;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
root /usr/share/;
}
}
}
server {
listen 8080;
listen [::]:8080;
server_name papa.fit www.papa.fit;
root /var/www/laravel_api/public/demo/;
index index.php index.html;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
答案1
您缺少ssl
指令以及证书配置。
改变
listen 8080;
listen [::]:8080;
到
listen 8080 ssl;
listen [::]:8080 ssl;
并将其添加到块内:
include snippets/ssl-papa.fit.conf;
include snippets/ssl-params.conf;
你的帖子里没有包含这些文件,所以我们不知道里面有什么,但我们假设它只是证书配置。在这种情况下,它应该足够了。