因为移动应用项目里面不需要访问根url,即 “http://www.domain.com/%E2%80%9D%E4%BD%86%E6%98%AF%E9%9C%80%E8%A6%81%E8%AE%BF%E9%97%AE%E6%A0%B9url%E7%9A%84%E6%96%87%E4%BB%B6%EF%BC%8C%E5%A6%82 “http://www.domain.com/licence.txt%E2%80%9D%EF%BC%8C%E6%89%80%E4%BB%A5%E6%83%B3%E8%A6%81%E4%BD%BF%E7%94%A8nginx%E5%88%A4%E5%AE%9A%E7%9B%B4%E6%8E%A5%E8%AE%BF%E9%97%AE%E6%A0%B9%E8%B7%AF%E5%BE%84%E4%B8%BA%E9%9D%9E%E6%B3%95%E8%A1%8C%E4%B8%BA%EF%BC%8Creturn 403。
第二个问题就是在server里面写入return 403,但是会直接返回nginx自带的403页面,在location里面写的规则也是,但是在location里面的其他规则则会返回自定义的403页面,请指教怎么才能返回自定义的页面?
第三个问题,nginx里面http自动跳转https,设定后页面一直打不开,不设定会跳内部400错误,也是不会跳转到自定义页面,请多看看,多谢!
默认环境phpstudy,cs架构版的最新版
部分代码截图如下:
server {
listen 1001 ssl;
ssl_certificate E:/Extensions/Nginx1.15.11/conf/ssl/www.domain.com.pem;
ssl_certificate_key E:/Extensions/Nginx1.15.11/conf/ssl/www.domain.com.key;
ssl_session_timeout 5m;
ssl_ciphers ………………………………………………………………;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
server_name www.domain.com;
if ($host != 'www.domain.com'){
return 403;
error_page 403 /error/403.html;
}
location /login {
return 403;
error_page 403 /error/403.html;
}
location / {
index index.php index.html error/index.html;
error_page 400 /error/400.html;
error_page 403 /error/403.html;
error_page 404 /error/404.html;
error_page 500 /error/500.html;
error_page 501 /error/501.html;
error_page 502 /error/502.html;
error_page 503 /error/503.html;
error_page 504 /error/504.html;
error_page 505 /error/505.html;
error_page 506 /error/506.html;
error_page 507 /error/507.html;
error_page 509 /error/509.html;
error_page 510 /error/510.html;
include E:/WWW/1001/nginx.htaccess;
autoindex off;
}
#这里原来有个rewrite为https的语句,由于无法运行,删掉了。
}
运行结果:
问题1结果(不会配置)
问题2结果:返回内部403页面
问题3结果:在倒数第二行里面原来有个rewrite为https的,但是有了就直接白屏,删掉后报400。
##由于要给以后所有应用都这么配,所以想要nginx解决问题。
##所属环境为phpstudy8.1.1.3,nginx为1.21.4(忘了反正一直是最新版)其余环境开关都没开。