How to solve add a custom error 503 page html on ubuntu apache2 using it with mod_jk and virtual host redirecting to tomcat - html

I tried all I found at apache documentation and other sugestions found at stackoverflow and blogs.
When I add the folloowing line to any configuration file like /etc/apache2/apache2.conf or /etc/apache2/conf.d/localized-error-pages or /etc/apache2/httpd.conf or /etc/apache2/sites-enabled/000-default:
ErrorDocument 503 "This is an error msg" or even an html message
ErrorDocument 503 "<h1> This is an error message </h1>
or an external url redirect ErrorDocument 503 http://www.google.com it works.
But when I try an internal redirect like ErrorDocument 503 /ERROR_503.html
or ErrorDocument 503 /error/ERROR_503.html I get the default message with last line:
Additionally, a 503 Service Temporarily Unavailable
error was encountered while trying to use an ErrorDocument to handle the request.
I tried to put the html error page at the DocumentRoot var/www, at var/www/error.
Try to uncomment all the file /etc/apache2/conf.d/localized-error-pages that sets all errors to custom pages with internationalization that are at /usr/share/apache2/error.
And as the messages inside this files are the same as the default, the line
Additionally, a 503 Service Temporarily Unavailable
error was encountered while trying to use an ErrorDocument to handle the request.
is not shown anymore. But if I change the line
`ErrorDocument 503 /error/HTTP_SERVICE_UNAVAILABLE.html.var`
at the localized-error-pages file to a new html placed at the same page, the error is back
and the page is not shown. If I edit the file HTTP_SERVICE_UNAVAILABLE.html.var nothing change at the browser message too.
Some more information: I'm using apache2 just to redirect all request on port 80 to tomcat at port 8089 via an worker. My configuration files are https://dl.dropboxusercontent.com/u/1105054/apache.zip

This took me way tooo long (partially due to spelling), but I thought I'd post my whole virtual host file since it might be useful.
You'll want to make sure you've specified a DocumentRoot, and that you do the ProxyPass /file.html ! before your main ProxyPass /.
<VirtualHost *:443>
DocumentRoot /var/www/html
#ProxyPreserveHost On
<IfModule env_module>
# Fake SSL if Loadbalancer does SSL-Offload
SetEnvIf Front-End-Https "^on$" HTTPS=on
</IfModule>
SSLEngine on
SSLCertificateFile file
SSLCertificateKeyFile file
SSLCertificateChainFile file
ProxyPass /maintenance-message.html !
ProxyPass /maintance-message_files !
ProxyPass / "ajp://localhost:8009/"
ProxyPassReverse / "ajp://localhost:8009/"
ServerName server.something.com:443
ErrorDocument 503 /maintenance-message.html
</VirtualHost>

In my case I just added this ProxyPass line to my virtualserver config:
ProxyPass /serverError.html !
ErrorDocument 503 /serverError.html
That tells the proxy to go to the DocumentRoot and search for the error page.
Also you may find useful this answer: https://stackoverflow.com/a/13019667

I faced the same issue too and after deep searching I found here the best (and only?) solution from #Loren.
Worked after setting ProxyPass /file.html ! before the main ProxyPass / and NOT after.
Also, DocumentRoot is needed as well.

Related

.htaccess ErrorDocument 404 doesn't work on localhost

I'm trying to implement a 404 error page. I have this project structure:
+Project
+---index.html
+---404.html
+---.htaccess
My .htaccess contains this line: ErrorDocument 404 /404.html
but this URL doesn't show my 404.html page:
http://localhost:63342/Project/wrong.html
Instead, I get the default Opera 404 page: https://ibb.co/XsFq5nZ
Whereas, my 404.html page looks like this: https://ibb.co/ZX7XB1d
The response from wrong.html is this: https://ibb.co/mJ2KztK
What is the problem?
ErrorDocument 404 /404.html
http://localhost:63342/Project/wrong.html
It would seem you have not specified a root-relative URL-path. From your URL structure, it should be:
ErrorDocument 404 /Project/404.html
UPDATE:
Try resetting to the default Apache error document:
ErrorDocument 404 default
Test that and then add your custom error document:
ErrorDocument 404 default
ErrorDocument 404 /Project/404.html
Make sure your 404.html file contains enough content. Some browsers will default an error response if the response received from the server is too small.

SSL Localhost Privacy error

I setup ssl on localhost (wamp), I made the ssl crt with GnuWIn32.
When I try to login with fb in Chrome I get the following message:
URL:
https://localhost/ServerSide/fb-callback.php?code=.....#_=_
Error:
Your connection is not private.
Attackers might be trying to steal your information from localhost (for example, passwords, messages, or credit cards). NET::ERR_CERT_INVALID.
localhost normally uses encryption to protect your information. When Chrome tried to connect to localhost this time, the website sent back unusual and incorrect credentials. This may happen when an attacker is trying to pretend to be localhost, or a Wi-Fi sign-in screen has interrupted the connection. Your information is still secure because Chrome stopped the connection before any data was exchanged.
You cannot visit localhost right now because the website sent scrambled credentials that Chrome cannot process. Network errors and attacks are usually temporary, so this page will probably work later.
My SSL Config:
Listen 443
SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5
SSLPassPhraseDialog builtin
SSLSessionCache "shmcb:c:/wamp/www/ssl/logs/ssl_scache(512000)"
SSLSessionCacheTimeout 300
<VirtualHost *:443>
DocumentRoot "c:/wamp/www"
ServerName localhost:443
ServerAdmin admin#example.com
ErrorLog "c:/wamp/logs/error.log"
TransferLog "c:/wamp/logs/access.log"
SSLEngine on
SSLCertificateFile "c:/wamp/www/ssl/ia.crt"
SSLCertificateKeyFile "c:/wamp/www/ssl/ia.key"
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory "c:/Apache24/cgi-bin">
SSLOptions +StdEnvVars
</Directory>
BrowserMatch "MSIE [2-5]" nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
CustomLog "c:/wamp/logs/ssl_request.log" \
"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
</VirtualHost>
My question is how to setup valid SSL certificate on localhost? or do I need to edit my configuration?
Allow Insecure SSL (localhost)
In Chrome (including Version 110), enable allow insecure localhost:
chrome://flags/#allow-insecure-localhost
Refer to this Stack Overflow for more information.
Allow Insecure SSL (other)
See "Your connection is not private. blah-bla-blah"...
Type thisisunsafe (key listeners pick it up).
Notes
If you are just curious if this works, browse this site which has a bad root ssl certificate. Other "bad ssl" sites can be found using badssl.com.
More about the chromium "override keyword":.
This is specific for each site.
The chrome developers also do change this periodically.
The current (v110) BYPASS_SEQUENCE is dGhpc2lzdW5zYWZl (which is base64 encoded).
1. When you see "Your connection is not private...NET::ERR_CERT_INVALID" warning on Chrome,
2. Just type "thisisunsafe" and wait.
Note: Last time this was tested, Chrome latest version was 107.0.5304.107
Your connection is not private
Attackers might be trying to steal your information from 10.10.10.10 (for example, passwords, messages or credit cards). Learn more
NET::ERR_CERT_INVALID
Type “badidea” or “thisisunsafe” directly on same chrome page.
Do this if you REALLY SURE about the link you are trying is safe. In my case I was trying to setup stackstorm locally using vagrant and virtualbox
Chrome version: Version 92.0.4515.131 (Official Build) (x86_64).
Source

Setting up Ghost on Subdomain with Hidden Port - Windows Server 2008 with Apache

Before I start, I should say I am running XAMPP on Windows Server 2008 R2. I have node.exe allowed through my firewall, as well as port 2368. I have also been following the instructions here with no success.
I have my Ghost installed here.
As you can see, Ghost is only loading with the port as part of the web address.
If you try and load the site without the port like so, you get an Internal Server error.
My vHosts file for Ghost is:
<VirtualHost *:80>
ServerName blog.theobearman.com
ProxyPreserveHost on
ProxyPass / http://127.0.0.1:2368/
</VirtualHost>
My config.js file is here. Please note that 198.37.105.108 in the config file is the IP of my server.
Error logs for the Internal Server error are as follows:
[Fri May 15 17:56:25.495296 2015] [proxy:warn] [pid 56352:tid 1580] [client 86.147.117.154:58787] AH01144: No protocol handler was valid for the URL /error/HTTP_INTERNAL_SERVER_ERROR.html.var. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule., referer: http://blog.theobearman.com/
I would appreciate it if somone could tell me what I need to do so that when you navigate to "http://blog.theobearman.com", Ghost will load without the need for the port as part of the web address.
Thanks in advance!
You likely need to enable the proxy module for Apache:
# Enable the modules.
a2enmod proxy_http
a2enmod proxy
# Restart Apache
service apache2 restart

What is wrong with my .htaccess? 500 Internal server error

would you know what the issue is?
This works:
SetEnv PHP_VER 5_3
SetEnv REGISTER_GLOBALS 0
ErrorDocument 404 /index.html
ErrorDocument 403 http://www.dsfds.lu
This doesn't work and return a "500 Internal server error":
SetEnv PHP_VER 5_3
SetEnv REGISTER_GLOBALS 0
ErrorDocument 404 /index.html
ErrorDocument 403 http://www.dsfds.lu
Redirect 301 /biographie-dfd-fdd/ biographie.html
You need to use the full URL as the second argument
Redirect 301 /biographie-dfd-fdd/ http://website.com/biographie.html

"Unknown MySQL Server" in SQLAlchemy w/ ModWSGI and flask

I'm running a web app on Flask using Sqlalchemy. On the debug server, the app runs fine. But when I try to run it from Apache using ModWSGI (changing none of my code), I suddenly get this error:
OperationalError: (OperationalError) (2005, "Unknown MySQL server host 'myremotehost.topleveldomain' (111)") None None
What's so mystifying about this is that the mysql server is fine, it's running, and this app can find it when and only when it's running using the flask debugging server. It also finds a MySQL server running locally with no problem.
I'm not even sure what code to show you guys to help, but here's where I call it:
engine = create_engine(DATABASE, echo=False)
db_session = scoped_session(sessionmaker(autocommit=False,
autoflush=False,
bind=engine))
here's what the url looks like:
mysql://username:password#mydomain.com:3306/dbname
...and here's the virtualhost code in httpd.conf:
<VirtualHost *:808>
ServerName localhostdomaingoeshere
WSGIScriptAlias / /path/to/app.wsgi
Alias /static /path/to/static
LogLevel info
ErrorDocument 502 /error
<Directory /path/to/app>
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
I'm sure it's something dumb, I partly just don't even know where to start since the error message doesn't make sense.
Not really a solution, but I switched over to gunicorn and that's way less of a headache.