nginx-location

In Nginx, how to match and entire URL and Query String and redirect to a URL and Query String

我是研究僧i 提交于 2019-12-11 10:25:56
问题 I have been searching for a while now, trying work arounds and haven't come up with anything useful. I have a (large) list of URL's from an site migration and need to match the entire URL + Query String and redirect to another URL. As far as I can see the following only matches /mens , but not the rest of the query string. rewrite "^/mens?brand%5B%5D=27&section%5B%5D=5&price-min=0&price-max=2000&sort=newest" "/t/gender/men" permanent; The reason it's important is that I have a bunch of

How to configure nginx as proxy_pass?

天大地大妈咪最大 提交于 2019-12-11 08:49:20
问题 I have use Certbot Nginx to install my nginx to Ubuntu 18.04. I also use Certbot to get the LetsEncrypt certificate. I use basic configuration such as use tcp 80 and 433 so I can get both http and https. Most of the configuration done by Certbot. my domain is http://example.com and provides static page. Bu I also have a folder and I can call it with http://example.com/myfolder. After I install nginx I try to use proxy_pass and https to my local rest_api services. If I type http://127.0.0.1

Can't adjust redirect in Nginx, for message with code 401 “Auth Required”

﹥>﹥吖頭↗ 提交于 2019-12-11 06:32:14
问题 I can't adjust redirect in Nginx virtual hosts config-file, specifically for "401 error message" (401 Authorization Required). My target: When I open address in web-browser, for example it'll be my.domain.com, I want adjust basic authentication and I wanna get custom html page with original design and original login form instead of simple browser window. screen shot So, for this realisation need adjust redirect on 401 message to my custom page. I did try it like this, but it doesn't gave to

Nginx bypass cache if upstream is up and use cache if down

妖精的绣舞 提交于 2019-12-11 06:19:53
问题 To bypass cache if upstream is up (max-age 1) and use cache if down (proxy_cache_use_stale) I created following config: proxy_cache_path /app/cache/ui levels=1:2 keys_zone=ui:10m max_size=1g inactive=30d; server { ... location /app/ui/config.json { proxy_cache ui; proxy_cache_valid 1d; proxy_ignore_headers Expires; proxy_hide_header Expires; proxy_hide_header Cache-Control; add_header Cache-Control "max-age=1, public"; proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504;

Nginx redirecting for specific list of arguments

梦想与她 提交于 2019-12-11 05:56:49
问题 I have a list of some obsolete arguments in URLs. arg1 arg2 arg3 ... argn I need to redirect any of the request having any of those arguments in the query part of the link, to a specific site. /page.html?arg1=sxx&arg2=uuu -> http://xxx.x.xxx.x /page.php?arg3= -> http://xxx.x.xxx.x /dir/dir/page/?arg2=111&& argn=xyyyy -> http://xxx.x.xxx.x /page.html (is not redirected but matched to other existing rules in nginx) Any idea how to express it nicely? For some reasons location has no arguments to

Unable to map upstream with folder in nginx server

孤街醉人 提交于 2019-12-11 01:57:46
问题 I want to map our system port 82 with 127.0.0.1:8080/runningSite and I am gettting exception with nginx config. upstream dev { server 127.0.0.1:8080/runningSite; } server { rewrite_log on; listen [::]:81; server_name localhost; location / { proxy_pass http://dev; proxy_set_header Host $http_host; } } Exception : nginx: [emerg] invalid host in upstream "127.0.0.1:8080/runningSite" in C:\nginx -1.8.1/conf/nginx.conf:85 Can anyone please help me where I am wrong. 回答1: You can use location like

Nginx Rule to Block Specific URL

戏子无情 提交于 2019-12-11 01:14:05
问题 Need some help in writing a rule to block the following request The url in question is: www.somesite.com/catalogsearch/result/?q=downloader I have tried the following, but this does not work location ^~ catalogsearch/result/?q=downloader { deny all; } I "think" the because the ? question mark is included is treating the url as a query string?? Regards 回答1: If you want to block access through the parameter q=downloader only at URL www.somesite.com/catalogsearch/result/ : error_page 418 =

Nginx case insensitive proxy_pass

血红的双手。 提交于 2019-12-10 23:51:58
问题 I've got a site called http://example.com , with an app running that can be accessed at http://example.com/app1 . The app1 is sitting behind an nginx reverse proxy, like so: location /app1/ { proxy_pass http://localhost:8080/; 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; } Adding the trailing slash to the proxy_pass field lets me "remove" the /app1/ part of the URL, at

Nginx location match regex for special characters and encoded url characters

主宰稳场 提交于 2019-12-10 11:26:24
问题 I've been trying so many things today and I am just not winning. I have one file in my site which got created by accident with a special character in it. As a result Googlebot has stopped crawling for 3 weeks now and Webmaster tools / Search console keeps notifying me and wanting to retest the url. All I want to achieve is to configure Nginx to match the following requests and redirect them to the correct location but regex has me stumped on this one. The unencoded URL string is: /historical

Proxy_pass ignoring port

喜欢而已 提交于 2019-12-06 15:40:44
问题 I have a CentOS server running NGINX listening to 80 and a DB servering an app on 8080. I want to be able to Type http://example.com/dev/abc and have it actually access http://example.com:8080/apex/abc or http://localhost:8080/apex/abc I have used this location configuration location /dev { proxy_pass http://example.com:8080/apex; } However when I try it out the url displayed is http://example.com/apex/apex the page is not found and the log says: 2018/06/14 12:51:33 [error] 7209#0: *2067 open