I am trying to run Shell In a Box (link) through another server (the computer running shellinabox is not accessible from the internet) . Ideally I could use ProxyPass in the Apache config to have a reverse proxy. Problem is I can't access the conf file. So I tried using .htaccess and I discover that I cannot use ProxyPass in there. So I tried and used mod_rewrite to do the job. Currently I have the following on the .htaccess file
RewriteEngine On
RewriteRule ^$ http://10.1.13.236:4200/ [P]
However while it displays the title correctly and if I open up the source code I can see there is something in the page, nothing is diplayed on the screen (it remains blank). My suspicion is that there are problems with AJAX and this kind of proxy.
What I am trying to accomplish with the mod_rewrite as close as possible behaviour to ProxyPass (Mirorr a website in a subdirectory).
Is this possible? Is there some other solution (I tried phproxy and khproxy but neither of them is able to display anything)?
Related
I recognize that this question is similar to others on this site. I have spent days reading these posts and trying different approaches. None has worked.
I am trying to use an Apache proxy server to map a particular URL to a new URL. I have a dedicated device (Black Box) on a local network which makes calls to original.remoteHost1.com. I wish to use the Apache proxy server on this local network to substitute new.remotehost2.com for original.remoteHost1.com when Black Box requests service. I am able to configure Black Box to point to the proxy server but Black Box does not expose an interface to change its target host for the HTTP service requests.
Black Box makes only two very specific requests:
http://original.remoteHost1.com/rectrack/file_name.php?data_1=text_string_1
http://original.remoteHost1.com/rectrack/file_name.php?data_1=text_string_1&data_2=text_string_2
which I wish to change to:
http://new.remotehost2.com/rectrack/file_name.php?data_1=text_string_1
http://new.remotehost2.com/rectrack/file_name.php?data_1=text_string_1&data_2=text_string_2
Acting as a proxy, the Apache server accepts the Black Box requests and forwards them to original.remoteHost1.com. I expected that I would be able to use rewriteRule in httpd.conf to change original.remoteHost1.com to new.remotehost.com, but I cannot get this seeming simple function to work.
I have tried using the following rewriteRule (as well as many variations) to substitute new.remotehost.com for original.host.com, but I can't seem to get Apache to actually make the substitution:
LoadModule rewrite_module modules/mod_rewrite.so
RewriteEngine on
RewriteCond %{HTTP_HOST} original.remoteHost1.com
RewriteRule ^(.*) http://new.remotehost2.com/$1 [P]
Does anyone have any idea why the new URL is not substituted for the original?
I was able to solve this problem. I don't recall why I tried this and I certainly don't know why it works. I'm running Windows 7. In the folder C:\Windows\System32\Drivers\etc\ is a file named "hosts". In that file, in a section related to localhost name resolution, I added the line:
127.0.0.1 original.remoteHost1.com
After doing this, the rewriteCond and rewriteRule acted as I had expected them to.
I am trying to rewrite a condition that can take any page that has numbers.html, lets say the like the following:
12345.html
33443.html
234545656.html
9797423.html
and just redirect it to index.php
RewriteRule ^([0-9]+)$ index.php [L]
I tried the following but it doesn't work, any help is very much appreciated.
Two immediate issues with your code:
you have to switch on the rewriting engine prior to using it and
if you want to match file names ending with .html, then you have to code that.
Have a try with this:
RewriteEngine on
RewriteRule ^([0-9]+)\.html$ index.php [L]
Then a few more hints:
the code you tried will only work in .htaccess style files. But the usage of such files has to be enabled first in your http server configuration.
a .htaccess style file has to be placed at the correct location, in this example within the folder actually holding the index.php file.
the rewriting module has to be installed and enabled, without those commands will not be available.
And a general remark:
Those .htaccess style files are notoriously error prone, hard to debug and they really slow down the http server, often for nothing. You should always prefer to place such commands inside the real host configuration of your http server. .htaccess style files are only offered as a last option for situations where you have no access to that configuration, for example when using a really cheap shared hosting provider.
I have a website (built in ruby with .erb extensions) with mixed content (like a Wistia video) and so want to have that URL as http://domain.com.
However, when users click on "register," I want to direct them to an EV SSL-encrypted https://subdomain.domain.com/register folder.
Both of the above URLs work just fine, and the https URL displays the green EV SSL properly.
BUT, if in the low-probability event a user were to type "http://*/register" into his browser's address bar, that goes to the same /register page and allows him to register on that non-encrypted page. I really do not want that to happen.
I want to redirect anyone who tries to access the /register file via http to only the EV SSL-encrypted one, that is: https://*/register
sorry for using * wildcard, but I can only post 2 links.
I'm using Ubuntu 12.04 OS on an apache2 server and generally modify via ssh on my Mac's Terminal app.
Put this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^subdomain\. [NC]
RewriteRule ^register(/.*)?$ https://subdomain.domain.com/register$1 [L,NC,R=301]
Thanks for replying so quickly, Anu. That may have worked, but Rackspace support used a 301 redirect in a .conf file, and it definitely worked:
/etc/apache2/sites-enabled/domain.com.conf:5
==================================
redirect 301 /register https://subdomain.domain.com/register
So first off, I am pretty familiar with codeigniter I've used it for multiple occasions. Right now I have a project too do for school and I installed codeigniter on the server but I am getting routing issues I believe.
So additional info about the server which is different from the normal environment I work with, the server uses SSH and it is very weirdly protected in my opinion. You also need a username and password to view the URL in the first place. (I think it's weird)
If this helps the url is:
https://clipper.encs.concordia.ca/~pyc353_2/
and credentials are (username: pyc353_2, password: FMaqRb)
Now I am able to see any page that I set as my 'default_controller' in the routes, but the problem is trying to go to any other page. Right now I'm trying to access the register controller and I just get 404'd (while it works if I set it as default)
I will link all the code I think may be relevant to the error, hopefully it's not server settings since I have no control over any change.
config.php
$config['base_url'] = 'https://clipper.encs.concordia.ca/~pyc353_2/';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
routes.php
$route['default_controller'] = "test";
.htaccess (there may be better code for doing this but I used it in the past no problem and the route doesn't work even if I remove htaccess and add back index.php to 'index_page')
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
</IfModule>
So I tried accessing my pagedifferent variations in the url such as: (stackoverflow won't let me post more than 2 physical links)
clipper.encs.concordia.ca/~pyc353_2/register
clipper.encs.concordia.ca/~pyc353_2/index.php/register
neither work although with /index.php/ the error message is: "No input file specified."
So I hope my explanations are clear enough, it's hard to explain something I don't understand the source problem. If you need any additional info feel free to ask. I really need to solve this to proceed at all for my project.
EDIT
I don't know if this is relevant but the 404 message is not even in the codeigniter style it just looks like a plain web 404
Also I am looking at the path on the server and this is the hierarchy: /www/groups/p/py_comp353_2 I don't know if that could affect anything also?
NEWER EDIT
Following what I found here: http://ellislab.com/codeigniter/user-guide/installation/troubleshooting.html
Changing index.php to index.php? (and removing htaccess) actually did make the routing work. Now I am happy enough with this and I can continue working, but being that it's an ugly solve would anyone know how to keep the routing working AND remove the index.php? from my URI?
It appears that your htaccess is not working.
To confirm, create a new PHP file and write this line:
echo phpinfo();
On that page try to search for "mod_rewrite", if it is enabled, you will see it under "Loaded Modules"
It is probable, it is not enabled.
Try this on your server:
a2enmod enable
Then restart the apache server.
For restarting on debian, this should work:
service apache2 restart
For CentOS, this should work:
apachectl restart
That always does not solve the problem.
Even then, try your CI installation in the normal mode after that. (With everything in normal mode: htaccess as before, and no index.php in the URL)
If it does not work, you may need to alter the apache config file httpd.conf
Try to search for this line:
#LoadModule rewrite_module modules/mod_rewrite.so
Uncomment it by removing the # sign
Restart Apache Server.
Test it now, again.
There could still be other things that you could do to enable mod_rewrite.
I have provided a link from my web site in my andoird app which is:
www.mysite.com/support
And i want this link to be redirected to:
www.anothersite.com
i have already tried com_redirect and entered support as source and http://ww.anothersite.com but i dont get any redirects and i get 404 error.
I am running Joomla 3.x and i want to know how i can do this with URL rewrites and no external components.
It seems not possible to do it within the Joomla backend (i tried many combination of menu items and the redirect module).
For sure you can write your redirect directly in your .htaccess (if you are using it) like this:
RewriteEngine On # Turn on the rewriting engine
RewriteRule ^support/?$ http://www.anothersite.com/ [R=301,NC,L] # Permanent Move
or
RewriteEngine On # Turn on the rewriting engine
RewriteRule ^support/?$ http://www.anothersite.com [R,NC,L] # Temporary Move
More info about URL rewriting and .htaccess are here: http://www.addedbytes.com/articles/for-beginners/url-rewriting-for-beginners/