addis_a
February 11, 2015, 3:23pm
1
Hi
We’re using proxy_pass to silently forward a website to a different URL.
Here is the code
location ^~/ {
proxy_pass http://www.example.org/ ;
}
So let’s say the site is example1.org .
Going to www.example1.com/ /history correctly shows that
page
that would be visibile at
www.example.org/ /history but I need to remove the folder
name
making it
example1.org .
How can I do this?
Thanks
Posted at Nginx Forum:
Maybe something like;
rewrite //([^/]+) /$1 break;
Posted at Nginx Forum:
Thanks, trying that gives me www.example1.com/ /history but
the
pages doesnt display…
Posted at Nginx Forum:
Enable debug and see the logs whats actually being rewritten.
Posted at Nginx Forum:
Will do…in case this helps…here’s my config
server {
listen 80;
client_max_body_size 4G;
server_name example1.com ;
passenger_enabled on;
root /home//current/public;
rails_env production;
keepalive_timeout 5;
location = / {
proxy_pass http://example1.com/ ; // This is to silently
redirect
the root of http://example1.com to http://example1.com/
}
location ~ ^/assets/ {
root /home//current/public;
expires max;
add_header Cache-Control public;
add_header ETag “”;
break;
}
location /system {
proxy_pass http://www.example.com ; // This is to silently redirect
http://example1.com/system to example.com/system , but to still show
example1.com/system in the address bar
}
location ^~/wcmc {
proxy_pass http://example.com/ ; // This silently redirects
example1.com/ to example.com/
}
}
This all works in that
going to example1.com gives me the page at example.com/
Clicking the links on the page take me to the correct page on
example.com ,
but show example1.com in the addressbar.
eg
example1.com/ /history
I need to hide the part of it.
Posted at Nginx Forum:
On Wed, Feb 11, 2015 at 11:35:03AM -0500, strtwtsn wrote:
Hi there,
Clicking the links on the page take me to the correct page on example.com ,
but show example1.com in the addressbar.
eg
example1.com/ /history
I need to hide the part of it.
It sounds like you want a request for /history/one to be proxy_pass:ed
to http://example.com/ /history/one, no?
“location ^~ /history/”, proxy_pass (Module ngx_http_proxy_module ),
and then you are responsible for “fixing” any links on the page if they
refer to “” at all.
Which part doesn’t work?
f
Francis D. [email protected]
We’ve got a website that is available at example.com .
A subsection of the page is available at example.com/folder_name/page1
example.com/folder_name/page2 etc
We need the pages below folder_name to be accessible at
example1.com/folder_name/page1 example1.com/folder_name/page2 etc
This is working apart from i’ve been asked to make the pages below
folder_name accessible without the folder_name
So it would be example1.com/page1 example1.com/page2 . They will still
be
below the folder_name, but the folder name must not show in the address
bar.
Hope this helps.
Thanks
Posted at Nginx Forum:
On Thu, Feb 12, 2015 at 03:06:26AM -0500, strtwtsn wrote:
Hi there,
We need the pages below folder_name to be accessible at
example1.com/folder_name/page1 example1.com/folder_name/page2 etc
location /folder_name/ { proxy_pass http://example.com ; }
So when the user makes a request of nginx for /folder_name/page1,
nginx does proxy_pass to example.com/folder_name/page1 and returns the
content, yes?
This is working apart from i’ve been asked to make the pages below
folder_name accessible without the folder_name
So it would be example1.com/page1 example1.com/page2 . They will still be
below the folder_name, but the folder name must not show in the address
bar.
So when the user makes a request of nginx for /page1, nginx should do
proxy_pass to example.com/folder_name/page1 and return the content, yes?
If “no”, what should nginx do when the user requests /page1?
Hope this helps.
I think I still understand the same thing. And I do not understand where
the problem is.
location / { proxy_pass http://example.com/folder_name/ ; }
and then presumably extra locations for the requests that should not be
handled by this proxy_pass mechanism.
What happened when you tried it?
f
Francis D. [email protected]