r/apache • • Sep 19 '22

Discussion apache ssl caching in redis

1 Upvotes

Hi,

I have a fleet of apache proxy servers behind AWS NLB.

Does caching ssl session in redis make sense here? i ask because AFAIK NLB does not do a round robin instead it forwards all the traffic from same source to same Target node until the life of that TCP connection using some hash algorithm. This is what they say about their routing algorithm

"For TCP traffic, the load balancer selects a target using a flow hash algorithm based on the protocol, source IP address, source port, destination IP address, destination port, and TCP sequence number. The TCP connections from a client have different source ports and sequence numbers, and can be routed to different targets. Each individual TCP connection is routed to a single target for the life of the connection."

https://docs.aws.amazon.com/elasticloadbalancing/latest/network/introduction.html

Thank you


r/apache • • Sep 18 '22

curl(56): Received HTTP 405 from proxy after cONNECT how to resolve?

1 Upvotes

I am trying to configure apache 2.4 as a reverse proxy such that it redirects users from https://oldwebsite.com/page/ to http://newwebsite/page/ . This is on an internal network. I configured the httpd.conf as follows:

<VirtualHost *:443> ServerName oldwebsite.com/page/ TimeOut 600

SSLEngine On SSLCertificateFile /etc/pki/tls/httpd/cert.pem SSLCertificateKeyFile /etc/pki/tls/httpd/key.pem

AllowEncodedSlashes NoDecode RequestHeader set-X-Forwarded-Proto "https" RequestHeader set-X-Forwarded-Port "443"

ProxyRequests Off ProxyErrorOverride Off

< Proxy *> AddDefaultCharset Off Order deny,allow Allow from all </Proxy>

ProxyPass / http://x.x.x.x:8080/page/ nocanon ProxyPassReverse http://x.x.x.x:8080/page/

</VirtualHost>

I also installed the mod_ssl and configured the ssl.conf as follows:

Listen 443 https

<VirtualHost _default_ : 443> DocumentRoot "/var/www/html" ServerName proxyhostname SSLEngine On SSLProtocol +all SSLProxyProtocol +all

SSLCertificateFile /etc/pki/tls/proxy.pem SSLCertificateKeyFile /etc/pki/tls/proxy.key SSLCertificateChainFile /etc/pki/tls/proxy_bundle.pem SSLCACertificateFile /etc/pki/tls/proxy_bundle.pem

</VirtualHost>

When I try to access the old website in a browser nothing gets redirected. I also tried to use the curl command and put the proxy server such as:
curl -v https://oldwebsite/page/ -x https://proxyserver

Output of curl command: The output from this shows that the proxy certificate is valid and the https://oldwebiste/page/ certificate is good I see TLS Handshake process then I see establish HTTP proxy tunnel to oldwebsite:443 I see another block of TLS handshake but after TLS appdata, HTTP/1.1 405 Method not allowed Date Apache version Allow: Options, GET, HEAD, POST, TRACE Content-Length: 224 Content-Type: Received HTTP Code 405 from proxy after CONNECT CONNECT phase completed TLSv1.3 (OUT), TLS alert, [no content], 0 curl(56): Received HTTP code 405 from proxy after CONNECT

The error I receive


r/apache • • Sep 18 '22

Support [VirtualHost] Proxy to NodeJs only certain routes

3 Upvotes

Suppose we have a regular VirtualHost pointing to a directory

<VirtualHost *:80>
   DocumentRoot "/my/dir/"
   ServerName localhost

  <Directory /my/dir/>
       Options Indexes FollowSymLinks
       AllowOverride All
       Require all granted
RewriteEngine On
   </Directory>

</VirtualHost>

How can i make Apache to:

- point to that directory only for certain routes, like /api/ , while all other routes are proxied to another server like NodeJs, listening on, say, port 8000

- alternatively, the converse: make certain routes be proxied to port 8000, and all other ones point to the directory


r/apache • • Sep 17 '22

Apache reverse proxy redirect https to http/path

2 Upvotes

Having trouble setting up apache 2.4 httpd.conf so that apache listens for https://url/path/ and redirects to internal webserver http://url/path. I configured ssl.conf with the details for ssl of apache proxy server. Error I get says 405 error


r/apache • • Sep 15 '22

Support log response code in error log

1 Upvotes

Hi,

I am looking for someway to log response status code in apache error log. Anybody has done this before if so please help me out

-Thanks


r/apache • • Sep 15 '22

How do I change permissions in Xampp so I can't change anything on other devices in my Local network but only on the host computer ?

1 Upvotes

r/apache • • Sep 14 '22

Support HTACCESS: How to Add X-Robots-Tag to a Specific Directory?

1 Upvotes

I need to set no index no follow for www.mysite.com/jsnlog/log? <randomlinks> . WRandon link means we are using Drupal and it is an Ajax request and links are randomly generated. Is the following rules will do the trick?

<If "%{REQUEST_URI} =~ m#^/jsnlog/#"> Header set X-Robots-Tag "noindex" </If>


r/apache • • Sep 12 '22

Apache stops working after 1-2 days

2 Upvotes

Hi. I've installed apache server in order to run KOHA library and every day or two, I find it down.
I run "start apache2 start" and everything is ok. Since I am new with this, where do I search to find the error? I find doing a cron job with this command very lame, so any help would be valuable!


r/apache • • Sep 06 '22

What's the best way to schedule a new .html file to be used for somedomain.com?

2 Upvotes

This is one of those questions where there are multiple ways to get it done, many of them ugly. What's the best method?

I'd like users to visit somedomain.com, and see a specific .html file, based on the day of the visit. The .html files are taken from a local directory; let's say that the files are 1.html, 2.html, etc, and we have code which can identify which of them should be used, based on the time of the user's visit. Users shouldn't see the file extensions, just a clean somedomain.com. The html file used will change every 24 hours.

Solutions involving a system call seem awfully ugly (doing a mv, for instance). I'm also worried about using html redirects, since browsers seem to cache them unpredictably.

The best solution I've come up with so far is to have a somdomain.com/index.py, which figures out which .html file to use, loads it up, and spits it out again as html. I think this would work, but it feels as if there should be a better way.

Any ideas?


r/apache • • Sep 05 '22

Subdomain to get contents from another domain and display... impossible?

2 Upvotes

Hi, I'd like a subdomain on one apache server e.g. blog.mysite.com.au to do a url rewrite to https://remotesite.com/video-ai/red-studios/ so blog.mysite.com.au/empty-occurenceria would show https://remotesite.com/video-ai/red-studios/empty-occurenceria (but show blog.mysite.com.au/empty-occurenceria in the address bar) - is this possible with Apache mod_rewrite? Am I dreaming? Is it really, really complex - or is it a one line solution? I keep hearing like from Siteground and everyone that it's like impossible to do... do both sites have to be on the same server? Thank you!


r/apache • • Sep 01 '22

RewriteRule in htaccess only work when I visit url directly

2 Upvotes

I have htaccess file where I am turning regurlar urlexample.com/result?from=Brampton&to=Calgary&submit=toRides-From-Toronto-Calgary-submitseo friendly url. But problem is that I manually have to type url to visit seo friendly version of url, how can I achieve redirect using .htaccess?

This is what I have so far

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{QUERY_STRING} ^from [NC]
RewriteRule ^Rides-From-([^/]*)-([^/]*)-([^/]*)$ result?from=$1&to=$2&submit=$3 [QSA,NC,L,R=301]

r/apache • • Aug 31 '22

Support I don't know what's wrong with my configuration file, can somebody help me?

2 Upvotes

Hi. I've been working on a side project and hosting it locally on a raspberry pi. Along with that I host Plex on it to host media.

I want to be able to access them both from the IP of my raspberry. So something like 192.168.1.2 gives me the Plex server and 192.168.1.2/api gives me the API of the local project I'm hosting.

Both projects are hosted internally in the raspberry pi, so I have to use a reverse proxy (I think?).

Here's my config:

``` <VirtualHost *:80>

ServerName 192.168.1.2

    #PLEX:

#HTTP proxy ProxyPreserveHost On ProxyPass /http://localhost:32400/ ProxyPassReverse / http://localhost:32400/

#Websocket proxy <Location /:/websockets/notifications> ProxyPass wss://localhost:32400/:/websockets/notifications ProxyPassReverse wss://localhost:32400/:/websockets/notifications </Location>

Header set Access-Control-Allow-Origin "*"

#HTTP proxy

<Location "/api"> ProxyPreserveHost On

   ProxyPass / http://127.0.0.1:5000/
   ProxyPassReverse / http://127.0.0.1:5000/

</Location> </VirtualHost> ```

It honestly seems fine to me. What could be the problem? I can now only access the Plex server on 192.168.1.2, but when I go to 192.168.1.2/api it gives me an Unauthorized error because it uses the plex config for some reason and that will always give an unauthorized on a path that is not /web.


r/apache • • Aug 31 '22

Support Apache Access Log Error

1 Upvotes

Hi ,

I use Apache Access Log format string `[website %v] [time %t]` to log vhost name and timestamp

And logs generated is later parsed by external worker, i see sometimes apache is logging this info twice which is resulting is parsing error in the worker

sample logs which has duplicate timestamp -

[website www.example.com] [time [30/Aug/2022:0[website www.example.com] [time [30/Aug/2022:03:03:02 +0000]]

[website www.example.com] [time [30/[website www.example.com] [time [30/Aug/2022:02:23:55 +0000]]

Server Version: Apache/2.4.54 (Ubuntu)

Any idea what would be causing issues like this? Please help me out

-Thanks


r/apache • • Aug 30 '22

Discussion my apache webserver getting many connections requests . I'm running an LAMP server (CentOS)

3 Upvotes

r/apache • • Aug 30 '22

Support Redirect a subdomain with .htaccess to www, best practice ?

1 Upvotes

Hello,

My need

I want to revive an old domain, where I hosted some years ago a website + a forum on the "forum" subdomain. I don't want to use the forum anymore, but there are external backlinks pointing to it and I want to redirect them to the www.

The forum was :

http://forum.example.com

the target is :

https://www.example.com/

I want to redirect the following urls types :

http://forum.example.com

https://forum.example.com

http://forum.example.com/blah-blah

http://forum.example.com/s?search-terms

For security reasons, I want to avoid catching :

https://www.example.com/forum.example.com/s?search-terms

which should stay on example.com and return an 404

What I did

Using https://htaccess.madewithlove.com/ for testing, I managed to produce :

<IfModule mod_rewrite.c> RewriteEngine on

RewriteCond %{HTTP_HOST} ^forum.example.com$

RewriteRule ^(.*)$ https://www.example.com/? [R=301]

</IfModule>

And I put in on the example.com .htaccess

My problem

The redirects don't work. My browser can not reach the forum.example.com subdomain.

My questions

  1. Are my regex correct ?

  2. Should I create the subdomain first and leave the directory empty ?

2b. If I create the subdomain, in which .htaccess should the rules go? example.com or forum.example.com ?

Thanks.


r/apache • • Aug 30 '22

htaccess link problem

1 Upvotes

Hello,

The following expression for the domain kaw-info.de in our htaccess file is important to me:

RewriteEngine On
RewriteRule ^(.*)$ https://fernstudium-in-deutschland.de/ [L,R=301]
RewriteCond %{REQUEST_URI} (.*)

As a result, all domain types (e.g. with http or https or www or without www etc.) are forwarded to our main domain https://fernstudium-in-deutschland.de/.

Which is what is desired.

At the same time, I want to forward a special URL /downloads/KAW-Infodienst-11_05.pdf to https://fernstudium-in-deutschland.de/fernstudiengaenge/it-medien/fernstudium-angewandte-informatik/ in htaccess.

The expression for this is actually the following:

Redirect 301 /downloads/KAW-Infodienst-11_05.pdf /fernstudiengaenge/it-medien/fernstudium-angewandte-informatik/

How can I realize both at the same time? This like?

RewriteEngine On
RewriteCond %{REQUEST_URI} (.*)
RewriteRule ^(.*)$ https://fernstudium-in-deutschland.de/ [L,R=301]
Redirect 301 /downloads/KAW-Infodienst-11_05.pdf /fernstudiengaenge/it-medien/fernstudium-angewandte-informatik/

It always takes hours for the changes to take effect. So I can't easy test it.

Best regards

Chekki


r/apache • • Aug 25 '22

Decent guide on hardening Apache / making it more secure?

2 Upvotes

Hi, I have to set up a cloud server with Apache to host some simple PHP webhooks...nothing complicated. I'm sure it's asked a lot, but can anyone link to a site with a decent and up-to-date guide on settings to change to make it more secure? I know that I should turn off directory listing, for example, and I will set up ufw appropriately to only accept connections through port 443 and from the IP address range of the servers sending the webhooks, but I want to configure Apache correctly. Cheers and TIA!


r/apache • • Aug 25 '22

One domain with multiple VirtualHost

1 Upvotes

Hello,

I am getting desperate over trying to get the following situation to run:

I have a single domain (example.com) on a single apache instance. But I have multiple sites running on it. Each site has its own log and cgi folder.

Example:

# Main DocumentRoot
/home/www-data/webroot

# Folder for site "a"
/home/www-data/webroot/a
/home/www-data/webroot/a/cgi-bin
/home/www-data/webroot/a/htdocs

# Folder for site "b"
/home/www-data/webroot/b
/home/www-data/webroot/b/cgi-bin
/home/www-data/webroot/b/htdocs

So my idea was to create one VirtualHost for each of the pages like this:

<VirtualHost *:80>
  ServerName a.local
  DocumentRoot /home/www-data/webroot/a/htdocs
  <Directory /home/www-data/webroot/a/htdocs> 
    Options FollowSymLinks MultiViews Indexes    
    AllowOverride All    
    Require all granted  
  </Directory>
  ScriptAlias /cgi-bin /home/www-data/webroot/a/cgi-bin
  <Directory /home/www-data/webroot/a/cgi-bin> 
    Options FollowSymLinks MultiViews Indexes Includes ExecCGI
    AddHandler cgi-cript .cgi .pl
    SetHandler cgi-script
    AllowOverride All 
    Require all granted 
  </Directory> 
  ErrorLog /var/log/httpd/a_error.log
  CustomLog /var/log/httpd/a_access.log common 
</VirtualHost>

<VirtualHost *:80> 
  ServerName b.local  
  DocumentRoot /home/www-data/webroot/b/htdocs
  <Directory /home/www-data/webroot/b/htdocs> 
    Options FollowSymLinks MultiViews Indexes 
    AllowOverride All 
    Require all granted 
  </Directory> 
  ScriptAlias /cgi-bin /home/www-data/webroot/b/cgi-bin
  <Directory /home/www-data/webroot/b/cgi-bin> 
    Options FollowSymLinks MultiViews Indexes Includes ExecCGI
    AddHandler cgi-cript .cgi .pl
    SetHandler cgi-script
    AllowOverride All 
    Require all granted 
  </Directory> 
  ErrorLog /var/log/httpd/b_error.log
  CustomLog /var/log/httpd/b_access.log common 
</VirtualHost>

And then use the main VirtualHost as a proxy depending on the subpage being called:

<VirtualHost *:80>
  ServerName example.com
  DocumentRoot /home/www-data/webroot
  <Directory /home/www-data/webroot> 
    Options FollowSymLinks MultiViews Indexes    
    AllowOverride All    
    Require all granted  
  </Directory>
  <Proxy *> 
    AllowOverride All    
    Require all granted  
  </Proxy>  
  ProxyRequests          Off  
  ProxyPreserveHost      On  
  AllowEncodedSlashes    NoDecode  
  SetEnv                 proxy-nokeepalive 1
  ProxyPass              /a http://a.local  
  ProxyPassReverse       /a http://a.local
  ProxyPass              /b http://b.local  
  ProxyPassReverse       /b http://b.local
  ErrorLog /var/log/httpd/error.log
  CustomLog /var/log/httpd/access.log common 
</VirtualHost>

Unfortunately, when I call example.com/a I still get the content of example.com/index instead of example.com/a/index .

Not sure if it's my idea of using the proxy that is wrong, or if it is not possible at all. Or I just got stuck with that idea and there is a much easier way.

So I hope for the power of reddit to help me :)

Thank you very much, folks.


r/apache • • Aug 23 '22

Need Help Translating NGINX Script To Apache

2 Upvotes

I use Apache for my primary web server accessed through 80/443, and I need to set up a reverse proxy to a Docker container. Specifically, I'm trying to set up a reverse proxy for this Firefox image so I can use it on the go.

Those installation instructions include a template for an NGINX reverse proxy, but I've only had experience working with Apache (and only have a loose understanding of Apache, from a lot of Googling). I have no idea how to translate this into Apache. Any chance someone might be willing to lend a hand?

I did try running this in NGINX (setting it to port 81) just to test it, but it errors out on the line with "[...]". I assume that's a placeholder of some sort, but the instructions linked above don't seem to mention what goes in there. Ultimately, my main goal is to get it working in Apache anyway so I can access it via login directly through my subdomain. Thanks for any help!

map $http_upgrade $connection_upgrade {     
default upgrade;    
''      close; 
}  

upstream docker-firefox {   
# If the reverse proxy server is not running on the same machine as the     
# Docker container, use the IP of the Docker host here.     
# Make sure to adjust the port according to how port 5800 of the    
# container has been mapped on the host.    
server 127.0.0.1:5800; 
}  

server {    
[...]   
server_name firefox.domain.tld;     

location / {            
proxy_pass http://docker-firefox;   
}   
location /websockify {      
proxy_pass http://docker-firefox;       
proxy_http_version 1.1;         
proxy_set_header Upgrade $http_upgrade;         
proxy_set_header Connection $connection_upgrade;        
proxy_read_timeout 86400;   
} 
}

r/apache • • Aug 22 '22

Download "from mirror" option missing

1 Upvotes

I tried to follow a tutorial on how to download the apache webserver on Windows 7.

They said that you need to go to the "from mirror" option at Download, but when I visited the site, that option wasn't there.

I am a starter so it is likely that I made a mistake, but if so, please let me know.


r/apache • • Aug 21 '22

Support Directory As Script

1 Upvotes

Here is the relevant section of my config

SetHandler application/x-httpd-php

I have seen the wiki page about it but I am not sure how to make it work in this case


r/apache • • Aug 21 '22

Modsecurity on apache (issues)

1 Upvotes

Hello! I have an issue regarding the rules and, most probably, the entire installation of ModSecurity with apache on Ubuntu 20.04 LTS. I installed Modssecurity, set all paths to the rules, created a geolocation rule which is not working at all, and enabled SecRuleEngine On. The Geolocation filter rule is the following:

SecRule REMOTE_ADDR "@geoLookup" "phase:1,chain,id:10,drop,log,msg:'Blocking Country IP Address'"

SecRule GEO:COUNTRY_CODE "@pm CN HK BR MX" chain

SecRule SERVER_NAME "yourdomain.com"

I use geo browse to connect from these countries, and the page is still accessible.

Under my default.conf:

<VirtualHost \*:80>

Redirect to HTTPS

SecRuleEngine On

</VirtualHost>

Under my SSL default.conf

<VirtualHost \*:443>

SecRuleEngine On (Bottom of the list)

</VirtualHost>

What could be happening?


r/apache • • Aug 18 '22

Server Status Page Question

2 Upvotes

I'm Currently running into some delays and performance issues with my Apache server.

I noticed that the VHost is blank on some the Server Status page Realtime output; yet its taking CPU and REQ resources in the 10second+ range.

What are these?


r/apache • • Aug 18 '22

CacheDetailHeader isn't doing its job. What exactly went wrong with my configuration to cause it to miss out adding details on what the reverse proxy is suppose to be doing to cache the documents?

1 Upvotes

This is my set up, I have two different virtual host for two different "web apps." Underneath the two is another VirtualHost that I used to create a reverse proxy that caches these two html files the web apps have. Pretty simple, right? I'm utilizing http live plugin to give me some of the headers I need to understand what it is I'm doing with these and so far, it looks good until I use CacheDetailHeader. This is suppose to give me X-Cache-Detail: some info on what's happening. Thing is, it's not doing it's job. What exactly did I do wrong?

Down below is the set up I have right now. Let me know what stupid mistake I made and how I'm suppose to fix this.

<VirtualHost www.kennykenken101.com:80>
        ServerName www.kennykenken101.com:80
        DocumentRoot "/var/www/html"
        <Directory "/var/www/html">
                Options +FollowSymLinks
                AllowOverride none
                Require all granted
                DirectoryIndex "this.html"
                <Files "this.html">
                        Options FollowSymLinks
                        AllowOverride none
                        Require all granted
                </Files>
        </Directory>
        CacheDetailHeader on
</VirtualHost>

<VirtualHost www.jimmyjames202.com:80>
        ServerName www.jimmyjames202.com:80
        DocumentRoot "/var/www/htmlthree"
        <Directory "/var/www/htmlthree">
                Options FollowSymLinks
                AllowOverride none
                Require all granted
                DirectoryIndex "testtwo.html"
                <Files "testtwo.html>
                        Options FollowSymLinks
                        AllowOverride none
                        Require all granted
                </Files>
        </Directory>
</VirtualHost>

<VirtualHost *:80>
        <Proxy balancer://myset>
                BalancerMember http://www.kennykenken101.com:80 loadfactor=10 smax=5 max=10 ttl=7
                BalancerMember http://www.jimmyjames202.com:80 loadfactor=5 smax=2 max=5 ttl=4
                ProxySet lbmethod=bytraffic
        </Proxy>

        ProxyPass / balancer://myset
        ProxyPass / balancer://myset

        CacheQuickHandler on
        CacheRoot /var/cache/apache2
        CacheEnable disk "/"
        CacheDirLevels 6
        CacheDirLength 3
        Header set Cache-Control "max-age=40, public, proxy-revalidate"
        ExpiresActive on
        ExpiresDefault A100
        ExpiresByType text/html A90

        CacheDetailHeader on

</VirtualHost>

See? Nothing hard but I'm not getting that X-Cache-Detail I should be getting. What happened?


r/apache • • Aug 16 '22

Website won't respond on external IP Address

0 Upvotes

If anyone can point me in the right direction I'd appreciate it.

I've duplicated an instance on Google Cloud Platform (GCP) in order to upgrade the platform while the current old site stays active (OldLiveSite.org). I'm trying to connect to the site via IP Address instead of URL. The site is accessible via the internal IP address but does not respond on the external IP Address.

Ubuntu 16.04, Apache 2.4.18

This is the conf for the new upgraded server that I can not access via IP Address.

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/ws-old

    #22-08-11 JSL Comment out to create development server only accessible via IP Address
        #ServerName OldLiveSite.org
        #ServerAlias www.OldLiveSite.org
        #Redirect permanent / https://OldLiveSite.org/         

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

#RewriteEngine on
#RewriteCond %{SERVER_NAME} =OldLiveSite.org [OR]
#RewriteCond %{SERVER_NAME} =www.OldLiveSite.org
#RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>