Suppose that the request url is:
http://ip:port/myapp/user/add
How can I get "myapp" in nginx.conf ?
I know /myapp/user/add can be got by using variable $request_uri, but I can't find about the variable that obtains the context of the url.
Many thanks.
Related
How can I check in NGINX if query parameter in URL was provided. Most examples have specific parameter in mind. I just want to check if any is provided, but I don't know in advance what are the parameter names.
I have a site all URL use method get, but one of them use post, so I want to resolve this in nginx
But the specific URL say me file not found
am struggling finding a solution with reverse proxy.
The goal is to be able to dynamically reroute, based on URI path, the incoming requests, e.g :
https://a.b.c/23432/IP.IP.IP.IP.IP/Path should be proxied to https://IP.IP.IP.IP:23432/Path
While it is working at first sight with
location ~ ^/(?<targetport>([0-9]+)?)/(?<targethost>[^/]+) {
proxy_pass http://$targethost:$targetport;
[...]
in the end, only the first element (index.html) is served correctly. The requests made by this page (let's say js/my.js) obviously forget the return path, and are generated to access https://a.b.c/js/my.js, and fail to be served.
I tried setting http_referer (even reverse_proxying the request to it) but it doesn't help as am unable to reparse it correctly
What am I missing here ?
Thanks for your help
Problem solved, the proxied site was prefixing all the resources with /, killing the initial path
I have a weird problem which don't know how to solve.
The usual behavior for .NET is if you have a URL like: /action?id=abc&=type=3
the server variable are like:
URL: /action
PATH_INFO: /action
QUERY_STRING: id=abc&=type=3
But here comes the weird behavior: when the request comes from mediapartners-google, the server variables don't split the URL at the question mark and are:
URL: /action?id=abc&=type=3
PATH_INFO: /action?id=abc&=type=3
QUERY_STRING:
So the routing engine is trying to find an action name called action?id=abc&=type=3 and it doesn't find it, providing a 404 error.
Does anyone knows why this happens?
For MVC when the routing engine has matched a route the rest gets stuffed into the optional parameter. It quite possible to have a route match before it reaches the question mark. Its looks like you need another route to handle this case. Also remember you need your routes in order of strongest to weakest as they are processed by the first route that matches.
I am trying to do this:
http://somehost.net/edit.php?url=http://www.youtube.com/watch?v=EgHY53dOZ-U
Forbidden
You don't have permission to access edit.php on this server.
Is there a way to fix this through javascript(jquery), cause I am passing argument through ajax call.
I have tried it this way but without success:
$('#videofrm').load('edit.php?url='+encodeURI($(this).siblings('a').attr('href'))
You should fix the chmoding issues on the server.
Edit
What your edit.php doing ? If it redirecting to somewhere else ? then echo the result url before redirecting.
You can follow Tomalak Geret'kal if you want/can rewrite the .htaccess. otherwise you need to pass the url without the http:// part and prepend an http:// on edit.php
If you don't have permission to access edit.php, then it doesn't matter how many different ways you try to request it: you don't have permission.
Fix the permissions on the server, likely using chmod if the server is on Linux.
Update
You have a server configuration issue. I can only replicate the problem when passing the string :// inside the querystring.
Try writing AllowEncodedSlashes On in your httpd config, as per this question/answer.
You will then need to make sure you encode your URI properly:
http://somehost.net/edit.php?url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv=EgHY53dOZ-U
(it looks like your encodeURI call should take care of that part)
AllowEncodedSlashes allows slashes to be present in the query string as long as they're encoded which, for some reason, is not the case by default. The docs say that failure produces a 404, not a 403, but I still think that this is the cause.
If you are not able to manipulate configuration options for your webserver, workarounds include:
Choosing a stand-in term for http:// like http!!! that you will programmatically revert in the PHP script;
If you always use http:// (as opposed to, say, ftp:// or some local path), just leave it off the query string entirely and prepend it to the input in your PHP script (preferred workaround).
Hope that helps.