i need rewrite for domain whois for example http://domainname.ltd/example.com must be call http://domainname.ltd/whois.php?d=example.com
i try location examples but not working.
you can do it like this:
server {
listen 80;
server_name test.com;
location = /whois.php {
proxy_pass http://your_origin_host.com
}
location ~ \/(.*) {
set $domain_query $1;
set $args "d=${domain_query}";
rewrite ^ /whois.php last;
}
}
Related
server {
listen 80;
listen [::]:80;
server_name _;
root /home/ec2-user;
# location / {
# proxy_pass http://sdc_servers;
# }
location /loaderio-73cc9f7580b0a0844a502ff1c98e9305.txt {
proxy_pass http://3.15.28.77/loaderio-73cc9f7580b0a0844a502ff1c98e9305/;
}
}
I am not sure where I am going wrong trying to serve this file, I am totally lost
location /loaderio-73cc9f7580b0a0844a502ff1c98e9305.txt { proxy_pass http://3.15.28.77/loaderio-73cc9f7580b0a0844a502ff1c98e9305/; }
Instead of passing the token in the proxy_pass, try something like
location /loaderio-9f8a9889007f8a2721b6245b80344b75.txt { root /<location_to_the_file>/loader/; try_files /loader.txt =404; }
loader - directory containing loader.txt which contains the actual
token provided by loader.io.
I am configuring a nginx revser proxy. The result should be when user type http://10.21.169.13/mini, then the request should be proxy_pass to 192.168.1.56:5000. Here is the nginx config:
server {
listen 80;
server_name 10.21.169.13;
location = /mini {
proxy_pass http://192.168.1.65:5000;
include /etc/nginx/proxy_params;
}
}
The above location block never worked with http://10.21.169.13/mini. The only location block worked is:
server {
listen 80;
server_name 10.21.169.13;
location / {
proxy_pass http://192.168.1.65:5000;
include /etc/nginx/proxy_params;
}
}
But the above config also match http://10.21.169.13 request which is too board.
What location block will only match 'http://10.21.169.13/mini` and no more?
UPDATE: tried and failed with the following:
location /mini {
proxy_pass http://192.168.1.65:5000;
include /etc/nginx/proxy_params;
}
location /mini/ {
proxy_pass http://192.168.1.65:5000;
include /etc/nginx/proxy_params;
}
The error is request not found.
Try this out:
server {
listen 80;
server_name 10.21.169.13;
# root /usr/share/nginx/html;
# index index.html index.htm;
location / {
# add something here to handle the root
# try_files $uri $uri/ /index.html;
}
location /mini {
proxy_pass http://192.168.1.65:5000;
include /etc/nginx/proxy_params;
}
}
Let me know if that works for you.
like these:
test1.sec.com 192.168.1.8:8001<br>
test2.sec.com 192.168.1.8:8002<br>
test3.sec.com 192.168.1.8:8003<br>
http://www.sec.com/test1/ 192.168.1.8:8001<br>
http://www.sec.com/test2/ 192.168.1.8:8002<br>
http://www.sec.com/test3/ 192.168.1.8:8003<br>
how to config the nginx.conf ?
You haven't provided much information, but based on what you gave, this should work:
server {
listen 80;
server_name test1.sec.com;
location / {
proxy_pass http://192.168.1.8:8001;
}
}
server {
listen 80;
server_name test2.sec.com;
location / {
proxy_pass http://192.168.1.8:8002;
}
}
server {
listen 80;
server_name test3.sec.com;
location / {
proxy_pass http://192.168.1.8:8003;
}
}
Then, for your www.sec.com, you'll need to add separate location blocks to catch the /test/ URIs.
server {
listen 80;
server_name www.sec.com;
location /test1/ {
redirect 301 $scheme://test1.sec.com;
}
location /test2/ {
redirect 301 $scheme://test2.sec.com;
}
location /test3/ {
redirect 301 $scheme://test3.sec.com;
}
#Rest of your config here...
}
Note: You have to specify your test location blocks before your root (/) unless you use a modifier to give them precedence.
server {
listen 80;
server_name localhost;
location / {
index index.html;
root /Users/Lin/Codes/JS/Emberjs/yeoman-ember/dist;
}
location ~* ^/json {
root
proxy_pass http://localhost:9292;
}
}
The configure kinda works, but it only pass
localhost:9292/json to localhost/json.
But What I want is
localhost:9292/json to 'localhost'
`localhost:9292/json/post to 'localhost/post'
I think what I need to do is set root or do some rewrite, Anyone has some idea?
add a rewrite rule before the proxy_pass
location /json {
rewrite ^/json(.*) $1;
proxy_pass http://localhost:9292;
}
I'm try to set up the subdomains with Nginx, but I get some error. The following is my config:
server {
listen 80;
server_name dimain.com *.domain.com;
root /path/to/fuelphp_project/public;
location / {
index index.php index.html index.htm;
if ($host ~ (.*)\.(.*) ) {
set $sub_name $1;
rewrite ^/(.*)$ /index.php/$sub_name/$1 last;
break;
}
if (!-e $request_filename) {
rewrite ^.*$ /index.php last;
break;
}
}
...
}
I want to the results like:
sub1.domain.com/c1/a1 -> domain.com/sub1/c1/a1
sub2.domain.com/c2/a2 -> domain.com/sub2/c2/a2
How to correct it?
server {
server_name sub1.domain.com;
return 301 "http://domain.com/sub1${uri}";
}
Would this work for you?
I just noticed an answer to this here: https://serverfault.com/questions/426673/nginx-redirect-subdomain-to-sub-directory
server {
server_name ~^(?<sub>[a-zA-Z0-9-]+)\.domain\.com$; # will cause the sub-domain to be placed in $sub
return 301 "http://domain.com/${sub}${uri}";
}
I think the regular expression also can be a very cool solution... Depends what you need.