【发布时间】:2021-06-27 10:43:06
【问题描述】:
我试图不将 http 重定向到 https....
我试图研究但发现什么都没有...
顺便说一句,我执行了这两个命令来创建新文件,而不是在启用的网站上使用默认文件:
sudo touch /etc/nginx/sites-available/imallbd
sudo nano /etc/nginx/sites-available/imallbd
然后:
sudo ln -s /etc/nginx/sites-available/imallbd /etc/nginx/sites-enabled/imallbd
这是我的网站启用文件
server {
server_name imallbd.com;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.html index.htm index.php;
charset utf-8;
# For API
location /api {
alias /var/www/imallbd/api/public;
try_files $uri $uri/ @api;
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
}
}
location @api {
rewrite /api/(.*)$ /api/index.php?/$1 last;
}
# For FrontEnd -> GraphQL
location /{
proxy_pass http://localhost:3001;
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;
}
location /admin{
proxy_pass http://localhost:3000/admin;
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;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/imallbd.com/fullchain.pem; # managed >
ssl_certificate_key /etc/letsencrypt/live/imallbd.com/privkey.pem; # manage>
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = imallbd.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name imallbd.com;
return 404; # managed by Certbot
}
请帮忙!!!顺便说一句,当我访问我的网站时,它给了我 502 bad gateway ......这不是我要问的问题,但如果你能给我一些帮助提示或答案,我将非常感激 :)
当我跑步时:
sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
如果您想了解更多我可以提供的详细信息或信息,请在 cmets 上告诉我!
提前致谢!!!
【问题讨论】:
标签: http nginx web https server