nginx-location

Nginx location match regex for special characters and encoded url characters

时间秒杀一切 提交于 2019-12-06 13:21:49
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-rainfall-trends-south-africa-1921–2015.pdf The encoded URL string is: /historical-rainfall-trends

configure nginx to make a background request

喜夏-厌秋 提交于 2019-12-06 08:54:33
I am building an application where I need to do some analytics on the api-data combination usage. Below is my nginx configuration - location /r/ { rewrite /r/(.*)$ http://localhost:3000/sample/route1/$1 redirect; post_action /aftersampleroute1/$1; } location /aftersampleroute1/ { rewrite /aftersampleroute1/(.*) /stats/$1; proxy_pass http://127.0.0.1:3000; } location /r/ is used to redirect the browser request http://localhost:80/r/quwjDP4us to api /sample/route1/quwjDP4us which uses the id quwjDP4us to do something. Now in the background I want to pass the id quwjDP4us to an stats api /stats

How to configure redirects to url with trailing slash in nginx?

孤者浪人 提交于 2019-12-05 16:46:21
I want to redirect URLs without slash to the path with trailing slash. So /some-url to /some-url/ And the rest of the URLs, like /some-url.xml /some-url? /some-url?q=v /some-url/ Should stay without redirection. I found this article https://www.ateamsystems.com/tech-blog/nginx-add-trailing-slash-with-301-redirect-without-if-statements/ in which author suggests to use following rule: location ~ ^([^.\?]*[^/])$ { try_files $uri @addslash; } location @addslash { return 301 $uri/; } Unfortunately this doesn't really work. Because url /some-url?q=v gets redirected to /some-url/ Could you suggest

Nginx Angular2/Angular routes

喜你入骨 提交于 2019-12-05 00:16:58
I have an Angular2/Angular app running inside a docker container and using nginx to serve it. So my app base = /myapp/. Everything works correctly when hitting the app using the base url i.e. www.server.com/myapp or www.server.com/myapp/ events { worker_connections 4096; ## Default: 1024 } http { include /etc/nginx/conf/*.conf; server { listen 80 default_server; root /usr/share/nginx/html; index index.html index.htm; include /etc/nginx/mime.types; underscores_in_headers on; location /myapp { # If you want to enable html5Mode(true) in your angularjs app for pretty URL # then all request for

Proxy_pass ignoring port

守給你的承諾、 提交于 2019-12-04 20:53:31
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() "/usr/share/nginx/html/apex/apex" failed (2: No such file or directory), client: 124.157.113.187,

Nginnx config for Yii 2 Advanced App Template

為{幸葍}努か 提交于 2019-12-03 07:23:33
I would like to configure the Nginx web-server in such a way that: Requests to the /index.php URI should be handled by public_html/frontend/web/index.php Requests to the /admin/index.php URI should be handled by public_html/backend/web/index.php Advice please where I'm wrong. Here is my config: server { listen 80; server_name yii2.lo; server_tokens off; client_max_body_size 128M; charset utf-8; access_log /var/log/nginx/yii2-access.log main buffer=50k; error_log /var/log/nginx/yii2-error.log notice; set $host_path "/srv/http/yii2/public"; set $yii_bootstrap "index.php"; index $yii_bootstrap;

Nginx- How can I serve my static content with https that has a proxy in location block?

自古美人都是妖i 提交于 2019-12-02 08:56:11
问题 My server listen 443 port and redirects the requests to another port in the server. Also my server listen 80 port and displays a static content the user when they browse http://www.xxxx.com But I want also to display static content when user browse https://www.xxxx.com How can I manage this ? My Nginx config file is ; server { listen 443 ssl; server_name xxxx.com; ssl_certificate /etc/nginx/ssl/nginx.crt; ssl_certificate_key /etc/nginx/ssl/nginx.key; location / { expires off; proxy_pass http:

How to configure redirects to url with trailing slash in nginx?

余生长醉 提交于 2019-12-01 05:31:11
问题 I want to redirect URLs without slash to the path with trailing slash. So /some-url to /some-url/ And the rest of the URLs, like /some-url.xml /some-url? /some-url?q=v /some-url/ Should stay without redirection. I found this article https://www.ateamsystems.com/tech-blog/nginx-add-trailing-slash-with-301-redirect-without-if-statements/ in which author suggests to use following rule: location ~ ^([^.\?]*[^/])$ { try_files $uri @addslash; } location @addslash { return 301 $uri/; } Unfortunately

Nginx rewrite urls with special characters

自闭症网瘾萝莉.ら 提交于 2019-11-30 09:47:15
问题 I just got a list of urls that needs to be rewritten into nginx example.com/cms.php/inspiration?fullsize > / example.com/shop/?category_id=27 > /garden/cushion.html example.com/shop/?2008=1&vare_id=10553&variant_id=2232 > /garden/cushion/black.html I tried with the following Simple rewrite rewrite /shop/?category_id=27 /garden/cushion.html permanent; Location rewrite location /shop/?category_id=27 { rewrite /shop/?category_id=27 /garden/cushion.html; } And with location where I commented

Nginx Yii2 configuration in different folders

≯℡__Kan透↙ 提交于 2019-11-30 09:43:06
问题 I faced with problem in configuring nginx server for yii2 basic app. Here is my service block file : server { listen 80 ; access_log /var/log/nginx/access-server.log; error_log /var/log/nginx/error-server.log; charset utf-8; location /fetch { root /usr/share/nginx/html/another_folder/web/; try_files $uri $uri/ /index.php$is_args$args; } location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document