第一个必选规则location = / { proxy_pass http://locolhost/index} 1. 第二个必选规则:处理静态文件请求 这是nginx 作为 http 服务器的强项处理静态文件请求, 有两种配置模式, 目录匹配或后缀匹配, 任选其一或搭配使用 location ^~ /static/ { root /webroot/static/;}location ~* .(gif|jpg|jpeg|png...
配置完以后访问。http://xxxx/train 提示404 找了好久才搞明白, location如果一个特定的url 要使用别名,不能用root,alias指定的目录是准确的,root是指定目录的上级目录,改动后即可以使用了 location /publicity { alias/usr/local/nginx/hzcloud-timp-front/; index index.html index.htm; }...
proxy_pass http://tomcat:8080/index } # 第二个必选规则是处理静态文件请求,这是nginx作为http服务器的强项 # 有两种配置模式,目录匹配或后缀匹配,任选其一或搭配使用 location ^~ /static/ { root /webroot/static/; } location ~* \.(gif|jpg|jpeg|png|css|js|ico)$ { root /webroot/res/; } #...
location ./ { proxy_pass http://123.57.1.35:8090/jeecg-boot/swagger-ui.html; } location @router{ #rewrite ^.*/index.html last; rewrite ^(.+)$ /index.html last; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 5...
index.html; } location / { # 匹配所有其他非精确匹配的请求 try_files $uri $uri/ =404; } location /images/ { # 匹配以/images/开头的请求,用于静态文件服务 alias /var/www/images/; } location /api/ { # 匹配以/api/开头的请求,用于反向代理到后端服务 proxy_pass http://backend_api_server...
proxy_passhttp://tomcat:8080/ } 2. Rewrite规则 rewrite功能就是,使用nginx提供的全局变量或自己设置的变量,结合正则表达式和标志位实现url重写以及重定向。rewrite只能放在server{},location{},if{}中,并且只能对域名后边的除去传递的参数外的字符串起作用,例如http://seanlook.com/a/we/index.php?id=1&u=...
nginx的默认端口是8080,我们想通过反向代理的方式直接访问nginx,然后也能看到这个猫 我们进入配置文件,添加一句配置 proxy_pass http://lo... nginx反向代理配置 1、访问www.123.com:8080跳转到127.0.0.1:8080 配置文件如下: listen: 监听的端口 server_name: 请求地址 proxy_pass: 目标地址 2、访问不同地址跳转...
proxy_pass http://www.so.com;break;} if ($testB ~* "B") { proxy_pass http://www.sogou.com;#break;} } } 希望满⾜某个条件的时候,⾛某个proxy_pass。但是如果多个if都满⾜,⽐如上例中的情况:在第⼀个if中没有break的时候,就会执⾏下⾯的;为了第⼀个匹配上之后就执⾏...
我选择了配置多个location。 location/ { root /data/html/;indexindex.htmlindex.html; }location/publicity { root /usr/local/nginx/hzcloud-timp-front/;indexindex.htmlindex.htm; } 配置完以后访问。http://xxxx/train 提示404 找了好久才搞明白, location如果一个特定的url 要使用别名,不能用root,alias...
2、nginx多个if里面proxy_pass: server { listen 127.0.0.1:80; set $test A; set $testB B; location / { if ($test ~* "A") { proxy_pass http://www.so.com; break; } if ($testB ~* "B") { proxy_pass http://www.sogou.com; ...