Jenkins is running behind IBM HTTP Webserver, and the Load Balancing is trying to monitor the Webserver for the error code to check if the Webserver is Up.
Because the security is enabled on Jenkins, GET/ call from Load Balancer is returning 403 Forbidden, is there a way this can be redirected or print "200 OK" instead, if the page is reached, rather returning "403"?
Also tried using the Rewrite engine in the httpd file
<VirtualHost *:80>
ProxyPass / http://AppServer:8080/
ProxyPassReverse / http://AppServer:8080/
ProxyRequests Off
AllowEncodedSlashes NoDecode
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} ^curl/*
RewriteRule ^/index.php$
</VirtualHost>
Still doesn't work. I am sure, my configuration in the httpd file not correct, any suggestions? index.php is placed in bin directory of the HTTP server.
You could use mod_rewrite to send requests for ^/$ with a user-agent of your monitoring script to some other static resource
Related
I have a docker installation running on my machine and I can access the site on my browser by going to mysite.local (defined to map to 127.0.0.1 in hosts file)
When I run ngrok http mysite.local it works fine but when I open the http://random_id.ngrok.io link
ngrok console shows:
GET / 301 Moved Permanently
I get a NET::ERR_CERT_COMMON_NAME_INVALID error and If I click on advanced->proceed to... http://random_id.ngrok.io (unsafe), it just shows
Tunnel www.random_id.ngrok.io not found
Worth nothing this rule in .htaccess even though it looks fine to me
RewriteCond %{HTTP_HOST} !^mysite.local
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
UPDATE ngrok http -host-header=rewrite mysite.local seems indeed to work but:
css and oher assets fail to load (the only css-related rule in .htaccess is: AddType text/css .chunk.css AddType text/css .css)
Looks like the rewrite rule is the issue to me.
Your rule states:
If the http host does not start with mysite.local,
then redirect to https://www.HOST/[...]
I'd recommend either removing the rewrite rule entirely or use ngrok's http host header rewrite functionality:
ngrok http -host-header=rewrite mysite.local
I have an apache server running on localhost:8888. The following Virtual Host rule points to my rails application on localhost:3000:
<VirtualHost *:*>
ProxyPreserveHost On
RewriteEngine on
RewriteRule "^/(.*)$" "http://localhost:3000/$1" [P]
ProxyPass "/ia" "http://localhost:3000"
ProxyPassReverse "/ia" "http://localhost:3000"
ServerName localhost:3000
</VirtualHost>
This works fine but the re-write rule is sending all requests to the rails server and I only want it to rewrite requests following http://localhost:8888/ia/*. I have tried:
RewriteRule "^/ia/(.*)$" "http://localhost:3000/$1" [P]
I have also tried:
RewriteRule "^\/ia\/(.*)$" "http://localhost:3000/$1" [P]
but this doesn't seem to re-write anything. Essentially, without the rewrite rule, if I go to http://localhost:8888/ia none of the images/css will render because it's not re-writing links to localhost:3000. What am I missing?
I'm using this configuration with the lines in this good answer (Rails Deployment Environment on Windows):
<VirtualHost *:82>
# Your server's web or IP address goes here.
# You can leave at localhost if deploying to
# company intranet or some such thing.
ServerName localhost
# Customize the next two lines with your app's public directory
DocumentRoot "C:/RubyStack-3.2.5-0/projects/app_name/public"
<Directory "C:/RubyStack-3.2.5-0/projects/app_name/public">
Allow from all
Options -MultiViews
</Directory>
RewriteEngine On
# Redirect all non-static requests to Rails server,
# but serve static assets via Apache
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)$ balancer://app_balancers%{REQUEST_URI} [P,QSA,L]
# Serves dynamic rails assets from multiple servers
# to improve performance. A Rails server such as
# thin or WEBrick must be running on at least one of
# these ports in order for Apache to serve your site
<Proxy balancer://app_balancers>
BalancerMember http://localhost:3001/
BalancerMember http://localhost:3002/
</Proxy>
# Support for far-futures expires header
<LocationMatch "^/assets/.*$">
Header unset ETag
FileETag None
# RFC says only cache for 1 year
ExpiresActive On
ExpiresDefault "access plus 1 year"
</LocationMatch>
</VirtualHost>
But browsing, I found other articles and other questions of other people who have configured Apache httpd in a different way, by adding or subtracting configuration lines.
Like here: http://www.varyonic.com/2011/06/using-apache-with-mongrel-or-thin-and-rails-3/#.VK5OhyuG9G6
What is it?:
ProxyPreserveHost On
ProxyPass /images !
ProxyPass /stylesheets !
ProxyPass /javascripts !
ProxyPass / balancer://thinservers/
ProxyPassReverse / balancer://thinservers/
Now, of course, I'm here to ask you: what is best for Rails 4 on Windows 8.1 / Windows 10?
The server Thin is the best for Windows 8.1/10? Mongrel? Other?
Alternatives to Apache for stability and speed?
The operating system is Windows and I can not change it.
My rails app seems to break when it answers on www.example.com, it previously was working fine with just example.com...however I've moved servers recently and would like to know the best way to redirect all www.example.com requests to go to http://example.com/.../
thanks.
This should do the trick, assuming that you have mod_rewrite enabled
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.example\.com
RewriteRule ^(.*)$ http://example.com$1 [R=301,L]
It depends on your server setup and there are different ways. You can just cname www in DNS to the root domain, for one way. If you are running Rails behind Apache then you can do it in Apache with mod_rewrite. If you are taking network requests straight into Rails with eg, mongrel (or webbrick) then you may have to configure those servers, or might have to use Rails routes ?
Hope that helps,
adricnet
According to the Apache's name-based virtual host documentation the first virtual host is the default host. I use this to make the first entry a catch-all that redirects every "undefined" request to the main site:
# Default catch-all
<VirtualHost *:80>
# Note the lack of a ServerName
RewriteRule ^(.*)$ http://www.example.com$1 [redirect=permanent]
</VirtualHost>
# Site 1 - www.example.com
<VirtualHost *:80>
ServerName www.example.com
[ the rest of the site config ]
</VirtualHost>
For extra credit you can set up a wildcard DNS entry so that every undefined host (e.g. asdfasdfasdfas.example.com) gets redirected to www.example.com.
You might not want to hear it but I suggest fixing what breaks instead. You've hard coded your domain somewhere in your app, probably in your routing but it is not possible to tell without the specifics of the error(s), and you need to remove that so you, or some other maintainer, won't have to deal with it again in the future.
How does Stack Overflow (and other web sites) remove the 'www' prefix when it's entered as part of a URL?
Is it a redirect, a rewrite or something else entirely?
Update: I'd specifically like to know in the context of IIS 6
On Apache, it looks like this (inside an .htaccess file):
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
An easy way to do this is using the Apache "Redirect" directive:
<VirtualHost *:80>
ServerName www.example.com
Redirect permanent / http://example.com/
</VirtualHost>
<VirtualHost *:80>
ServerName example.com
# remainder of server configuration goes here
</VirtualHost>
The Redirect directive automatically preserves anything following the / in the URL. I find this method easier to read and understand than the Rewrite method.
Firing up Fiddler, we can see that the server responses with a "301 Moved Permanently" status and refers it to http://stackoverflow.com .
Since StackOverflow is hosted on Windows 2k8 IIS7 they set up this redirect straight away in IIS7.
FYI:
a list of HTTP statuses
If you are a .NET developer you might know "Respose.Redirect" , this creates a 302 Object Moved status. Search engines like 301 status codes in this case better, because they know they should not come back to www.stackoverflow.com in the future.
You can do it several ways, using mod_rewrite and redirecting is my favorite. Something like this:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.cuenca.co$ [NC]
RewriteRule ^(.*)$ http://cuenca.co/$1 [R=301,L]
redirect. the sub-domain "www.stackoverflow.com" would simply redirect to "stackoverflow.com".
You need a default dns entry added pointing to your web server.
ping site.com and verify ip is pointing to webserver, if not you need to get the default DNS entry added.
for a basic setup:
You'll have to add host headers http://www.visualwin.com/host-header/
Create 1 site with a hostheader of www.site.com
In the Home Directory tab, set it to a permanent redirect to http://site.com
Create a 2nd site with a host header of site.com
If you want www.site.com/file.html to redirect to site.com/file.html you will need a more advanced setup with something like ISAPI_Rewrite or use custom 404 pages to do it.
You can do what mod_rewrite does for Apache, with a comparable URL rewriter for IIS. A good one is IIRF. The rule is:
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [I]
RedirectRule ^(.*)$ http://example.com/$1 [R=301]
You can also wildcard the hostname like so:
RewriteCond %{HTTP_HOST} ^(.+)\.example\.com$ [I]
RedirectRule ^(.*)$ http://example.com/$1 [R=301]
IIRF is free to use.
For apache
<VirtualHost *:80>
ServerName yourdomain.tld
ServerAlias www.yourdomain.tld