我们使用迁移到另一个系统的tomcat应用程序。附加的还有一个MSSQL报表服务器。应用程序最终需要是只读的。目前我们还需要为某些客户输入一些数据。我使用nginx,所以tomcat服务和报表服务只需要一台服务器。现在我想使用nginx location方法来阻止某些请求。
在regex101.com的帮助下,我创建了一个用于nginx的regex。我已经试着改变位置块的顺序了。但是,我不能让它工作。下面是指向regex的链接,在这里您可以看到只有被阻止的url是彩色的:
https://regex101.com/r/w3oy0M/1/
代码如下:
server {
listen 443 ssl;
server_name subdomain.domainname.com;
ssl_certificate c:\cert\public.crt;
ssl_certificate_key c:\cert\private.rsa;
location / {
proxy_pass https://subdomain.domainname.com:8443;
}
location ~ "https:\/\/subdomain\.domainname\.com:8443\/(?!.*customer\/510|.*customer\/10638)(.*\/edit|.*\/new|.*\/archive)" {
# TEST URL FOR NOT ALLOWED REQUESTS
return 301 https://www.google.com;
}
location /Reports {
return 301 https://subdomain.domainname.com:7443/Reports;
}
}