The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,380 other followers

Archive for the ‘Apache2’ Category

Ben, blogging: Show the complete apache config file

Posted by jpluimers on 2018/03/20

Quite a while back, I got attended to Ben, blogging: Show the complete apache config file:

If you really want to see all the complete config settings, there is no existing tool for that. This Stack Overflow page  answered this question pretty well: You can use apachectl -S to see the settings of Virtual Host, or apachectl -M to see the loaded modules, but to see all settings, there is no such tool, you will have to go through all the files , starting from familiar yourself with the  general structure of the httpd config files.
… script …

The usage is simple: Run it as python  CombineApacheConfig.py . Since there is no additional parameters given, it will retrieve the default Ubuntu apache config file from  /etc/apache2/apache2.conf and generate the result complete config file in /tmp/apache2.combined.conf. If your config file is in different location, then give the input file and output file location.

Note: Apache server-info page http://127.0.0.1/server-info also provide similar information, but not in the config file format. It is in human readable format. The page works only when it is open from the same computer.

Since I could not find how to post comments there, and it works better for me having a repo, I put it into a gist with attribution to hist post: https://gist.github.com/jpluimers/fd300f3a500cbc78cd862d2a248e7b03
I need to adapt it for OpenSuSE; until then run it as this:
python CombineApacheConfig.py /etc/apache2/httpd.conf /tmp/apache2.combined.conf

–jeroen

 

Posted in *nix, *nix-tools, Apache2, Development, Linux, openSuSE, Power User, Python, Scripting, Software Development, SuSE Linux | Leave a Comment »

301 & 302 Redirect Generator Tool

Posted by jpluimers on 2017/12/19

[WayBack301 & 302 Redirect Generator Tool is a simple and cool tool:

Generate code to permanently or temporarily redirect your old URL to a new URL using htaccess, PHP, HTML, JavaScript, ASP or ASP.Net

Although using .htaccess files requires Apache to allow AllowOverride All which you might not want to, so here are a few other options and links you might want to check out:

–jeroen

Posted in *nix, Apache2, Development, HTML, HTML5, Power User, Software Development, Web Development | Leave a Comment »

OpenSuSE Tumbleweed: When apache breaks with “Invalid argument: AH00069: make_sock: for address [::]:443”

Posted by jpluimers on 2017/06/28

I had this strange break down of Apache 2 after updating to the most recent openSuSE Tumbleweed in the /var/log/apache2/error_log:

[Wed Jun 28 10:04:19.955991 2017] [ssl:info] [pid 27786] AH01887: Init: Initializing (virtual) servers for SSL
[Wed Jun 28 10:04:19.962449 2017] [ssl:info] [pid 27786] AH01876: mod_ssl/2.4.26 compiled against Server: Apache/2.4.26, Library: OpenSSL/1.0.2k
AH00558: httpd-prefork: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
[Wed Jun 28 10:04:20.029863 2017] [core:crit] [pid 27786] (22)Invalid argument: AH00069: make_sock: for address [::]:443, apr_socket_opt_set: (IPV6_V6ONLY)
(98)Address already in use: AH00072: make_sock: could not bind to address [::]:443
(98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:443
[Wed Jun 28 10:04:20.029935 2017] [mpm_prefork:alert] [pid 27786] no listening sockets available, shutting down

This didn’t give any results for processes having port 443 open:

# /usr/bin/netstat --verbose --all --numeric | grep 443

The commands below didn’t help much either.

So I started digging in port 443 binding:

Read the rest of this entry »

Posted in *nix, Apache2, Linux, openSuSE, Power User, SuSE Linux | Leave a Comment »

Hosting Grumpydev Imageflair locally

Posted by jpluimers on 2017/04/06

Even though StackOverflow and StackExchange now have implemented their own ImageFlair, I still like the original imageFlair that Grumpydev made at Stack Overflow – Share Your Flair – Now in PNG! | GrumpyDev

Grumpydev Imageflair

Stackoverflow imageflair

Stackoverflow imageflair

Alas, the Grumpydev site doesn’t properly support https and Grumpydev cannot change it because of shared hosting limitations, so I wanted to host ImageFlair locally and even see if I could make it StackExchange aware:

Stackexchange flair

Stackexchange flair

Well, I need to do that propertly another time as the first thing I bumped into was this:

PHP Fatal error: Call to undefined function imagecreatefrompng() in /srv/www/vhosts/pluimers.com-ssl/stackoverflow/imageFlair/imageFlair.php on line 42

For now I’ve fixed the first by installing php5-gd (although an SO answer suggests php-gd, openSuSE uses the php-version number for installing modules).

zypper install php5-gd
php -m
rcapache2 stop
rcapache2 start
rcapache2 status

This will install the module, check with php if it is indeed installed, then restart apache to let it use the updated module.

After that, I bumped into a second thing: the image is blank.

Blank imageFlair

Blank imageFlair

I also bumped into a third thing: the .htaccess file rewrite doesn’t work:

https://www.pluimers.com/stackoverflow/imageFlair/so/1.png gave me a 404 error whereas https://www.pluimers.com/stackoverflow/imageFlair/imageFlair.php?userid=1&mode=so “works” (i.e. generates a blank image).

That one was sort of easy to solve.

First of all, apparently I didn’t have all the required apache modules installed. The not-so-easy part is that apache uses two different aliases for modules: the ones listed by apache2ctl -M 2>&1 | sort are in a different format than the ones you mention in .htaccess and .conf files. Oh and of course the -M (nor the -t -D DUMP_MODULES) aren’t listed ore hinted in the apachectl documentation: that would be too easy. They are listed in the httpd2 documentation.

The .htaccess file needs mod_rewrite and mod_expires, but apache2ctl names them rewrite_module and expires_module.

Enabling these was easy, but you have to remember that a2enmod strips the prefix/suffix of the module name (I already had expires_module (shared) installed so this only shows how to enable mod_rewrite):

a2enmod rewrite
rcapache2 stop
rcapache2 start
rcapache2 status

NB: mod_rewrite wasn’t enable by default and before enabling it, read about the risks of mod_rewrite.

Then it still didn’t work, and then it occurred to me that likely I didn’t even have Apache2 allow for using .htaccess as the regexes in the .htaccess were fine. And indeed: .htaccess wasn’t enabled according to the steps at Making sure .htaccess and mod_rewrite are working as they should | Bolt Documentation. And indeed, the Apache documentation indicates when (not) to use .htaccess.

By setting the AllowOverride to both FileInfo as specified by RewriteRule and Indexes as specified by ExpiresActive (trying to refrain from AllowOverride All) for only this specific directory, I think I struck the right balance:

And the final thing is that the logic around StackExchange flair is a tad more complex than I hoped for. And on that bombshell…

–jeroen

Posted in *nix, Apache2, Development, Linux, openSuSE, PHP, Power User, Scripting, Software Development, SuSE Linux | 1 Comment »

node.js – a nightmare to get started. Did I try the wrong technology for my problem?

Posted by jpluimers on 2017/03/08

Most of my web-stuff is on Apache. Which works fine, has TLS/SSL enabled, etc.

But I wanted to do server-side JavaScript. Which somehow is a forrest without trees, or a nightmare to get started, especially on OpenSuSE.

First of all, virtually all examples explain how to run node as a script. But none explain where to save it, how to run it as a service (and restart when it crashes: it will crash) or how to run multiple sites under it. And the scripts seems to listen to a TCP port by themselves so they operate as a full server by themselves. Nice for a fully fledged portal, but not for some one-offs.

Some links below hopefully will get me re-started later on, but for now, I’ve given up: the out-of-the-box experience is totally non-intuitive.

Maybe what I really want is something else: I want JavaScript stuff that normally renders a page in the browser through the dom to run server side so I can run XMLHttpRequest to various places without bumping into CORS stuff but still render a page DOM.

If you know a better way to do what I want (serving small mostly single-page scripts written in an easy to debug/trace language) let me know.

So basically work around this:

XMLHttpRequest cannot load http://myApiUrl/login. No
'Access-Control-Allow-Origin' header is present on the requested
resource. Origin 'null' is therefore not allowed access.

Read the rest of this entry »

Posted in *nix, Apache2, Development, JavaScript/ECMAScript, Linux, openSuSE, Power User, Scripting, Software Development, SuSE Linux | 1 Comment »

 
%d bloggers like this: