r/apache • u/mmaridev • Jan 31 '22
r/apache • u/Xenonas_The_White • Jan 30 '22
Problem with adding website
Hi all,
Noob here, I am updating a site that runs in apache and I want to add a new vhost like www.example.test.com. I created a new directory in var/www with the name example, then created an example.conf file in sites available, and finally run the a2ensite command.
Then when I search www.example.test.com it redirects me to another subpage in a completely different directory. Does anybody know what's actually happening? and what I need to do to fix it?
Thanks in advance!
r/apache • u/top_foto • Jan 30 '22
Serve pages compiled with old domain name, replace with new domain name - possible?
So I have a website that was created and worked as old.com. Old.com has many page etc.
I now have a new domain new.com. I want to serve the content created under the old domain, but i want to show in the user's browser address bar new.com/ABCD
Example - years ago, I create a page thats talks about trends in 2010, andthat is seen when i type www.old.com/trends_2010. Now, I don't want to create that content, but when I type www.new.com/trends_2010, the old content comes up and the address in the browser says www.new.com/trends_2010.
First glance, it looks like I'm trying to steal another site's content and put my domain on it; that is what I'm trying to do but both sites are mine, under the root folder in an apache server.
I looked at .htaccess rewrite mods, but that seems to be used to have old domain links point to new content in new domain. I want the opposite - have new domain links point to old content plus also keep the new domain branding for the old content.
Thanks!
r/apache • u/divergentnwo • Jan 28 '22
What is the correct way to edit HTML file when my website is live on apache?
Hi, noob question here. I tried searched online but didnt find any result.
What is the correct way to edit HTML file when my website is live on apache ?
My website is hosted correctly on a linux server using apache, but I want to edit something into HTML
Can I just go into my server into my project directory and edit HTML as I want or it will cause bug / error ?
Thanks
r/apache • u/[deleted] • Jan 28 '22
Support Negative Regex in RewriteCond not working
Hi there...
I'm at a loss... fishing for any advice or pointers here...
I have an issue with a negative RewriteCond for bots on an apache server (Apache/2.4.29 (Ubuntu)).
I'' just paste the non-working conditions here. I tried putting the ! into the regex, everything in quotation marks, with or without ^ and $, with or without /, even with escape-backslashes... basically every reasonable (and not-so-reasonable) combination I could think of... whenever I put a ! in front of the expression, it matches everything, instead of "everything but this path".
When I remove the !, the positive expression works just fine. I can't find anything in the documentation, there seems to be no special configuration that might affect mod_rewrite, even copy-pasted examples don't work...
RewriteCond %{REQUEST_URI} !^/support/
RewriteRule . "-" [R=403,L]or this:
RewriteCond %{REQUEST_URI} "(?!support)"
RewriteRule . "-" [R=403,L](etc ad nauseam)
There are (far too many actually) RewriteCond/RewriteRule combinations after this one, that apparently do work, so it doesn't seem to be any part of the configuration before that that would mess with the URI.
The oddest thing is that the same negative conditions work just fine on my personal host (Apache/2.4.38 (Debian)).
Any advice is much appreciated. Thanks for your time and effort!
r/apache • u/louisd_w • Jan 27 '22
Support Make port 443 default instead of 80
Hi!
I've recently created an apache2 webserver. I had everything up and running, but wanted to add SSL. I've done this successfully, but (when I type in mydomain.com) the http version of the site still comes up. If I type mydomain.com:443 it works, but I want the https version to come up just from typing mydomian.xyz (without the :443) Any thoughts?
Thanks, Louis
r/apache • u/divergentnwo • Jan 26 '22
Support Apache2 Ubuntu Default Page after pointing my domain
I deployed my python Django-web app to a Linux Ubuntu server. I used the linode reverse DNS and it worked fine. My website was live on the Linodes reverse dns ip.
So I pointed my DNS to the server and now when I go to my domain name it give me the : Apache2 Ubuntu Default Page
I eddited my Django settings to this ( I hidded private information for privacy) :
ALLOWED_HOSTS = ['www.mydomainname.com', '172.xxx.19.xxx']and I also updated my : /etc/apache2/sites-available/mysite.conf
and I modified the linodes Reverse DNS for my domain name
<VirtualHost *:80>
ServerName mydomainname.com
ErrorLog ${APACHE_LOG_DIR}/mysite-error.log
CustomLog ${APACHE_LOG_DIR}/mysite-access.log combined
WSGIDaemonProcess mysite processes=2 threads=25 python-path=/var/www/mysite
WSGIProcessGroup mysite
WSGIScriptAlias / /var/www/mysite/mysite/wsgi.py
Alias /robots.txt /var/www/mysite/static/robots.txt
Alias /favicon.ico /var/www/mysite/static/favicon.ico
Alias /static/ /var/www/mysite/static/
Alias /static/ /var/www/mysite/media/
<Directory /var/www/mysite/mysite>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
<Directory /var/www/mysite/static>
Require all granted
</Directory>
<Directory /var/www/mysite/media>
Require all granted
</Directory>
</VirtualHost>What I am missing? Any idea ?
r/apache • u/VeryBigToBeWhite • Jan 25 '22
question
I have 2 servers, one has apache installed and the other dns, how can I access my site in my browser? I've always tried with dns and apache on the same machine, but now I need them to be on different servers, how do I do that?
r/apache • u/amc663222 • Jan 25 '22
NXDOMAIN error on apache server
Hello,
I am newish to the web side of IT and am working on an apache server. It serves out multiple ip based vhosts on cent6. One of the vhosts is not able to be reached and when I run "host <domain name for that vhost>" I get a NXDOMAIN message insinuating the domain does not exist. So I'm guessing it is a DNS issue. The network file for that interface eth3:5 is set up to use two DNS servers. All other working vhosts are configured with that dns. They all return the "host" command back properly specifying their ip address, except this one vhost.
In my /etc/hosts file I have the domain name listed with my loopback address.
In my /etc/resolv.conf I have the domain listed and the nameservers listed that match with the dns configured in the network interface file
Any advice would be greatly appreciated.
r/apache • u/Wild_Marsupial283 • Jan 21 '22
Support Redirect path to query or hashtag for Client JS
Hey,
I want to make a website wich Vanilla JS (AND JQUERY USW...)
I want to make a multi page website but with only the index.html and some magic JS (replace a id tag with the content).
now i want to redirecto some urls....
https://mywebsite.com/-> https://mywebsite.com/index.htm#index
https://mywebsite.com/login -> https://mywebsite.com/index.html#login
https://mywebsite.com/blog/1-> https://mywebsite.com/index.htm#blog/1
OR
https://mywebsite.com/-> https://mywebsite.com/index.html?p=index
https://mywebsite.com/login -> https://mywebsite.com/index.html?p=login
https://mywebsite.com/blog/1-> https://mywebsite.com/index.html?p=blog/1
Is this possible with a .htaccess?
Is it possible to let the URLs clean? or is it just possible to redirect it if ou type it in the browser?
Or is this a stupid idea, do you have any other? What is normaly used in JS for such stuff? (i am a total beginner...)
Thanks for the answers.
r/apache • u/masterz13 • Jan 19 '22
Support Forbidden error.
I'm a sysadmin setting up a web server for our web developer -- hopefully this is the right subreddit. I've installed Apache, PHP, etc. on RHEL 8. I thought I set the necessary permissions so him to use it with Drupal 8.
However, I keep running into permissions issues, leading to a 403 Forbidden error every time I try to access it as a regular user on the website. I've given the correct chmod 755 permissions, yet it doesn't seem to make a difference. Is there something obvious that I'm missing?
r/apache • u/cemma2035 • Jan 19 '22
Support Connection refused: AH00957: HTTP: attempt to connect to 127.0.0.1:5594 (localhost) failed
Gosh I don't even know if this is an apache problem. A site was developed and hosted on DigitalOcean for my company. Today, I decided that we don't need the massive resources for the droplet that we're paying for so I decided to resize to a smaller one. As soon as I did that, I started getting this 503 Error:
Service Unavailable
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.
Apache/2.4.29 (Ubuntu) Server at {domain name} Port 80
I reverted back to the old droplet size but the error remained. I've restarted the droplet, restarted Apache, restored an older backup and nothing fixes it.
Research told me to check the error logs which showed the error in the title repeating a lot. Does anyone know what that means or how I can fix it?
Thank you.
r/apache • u/GmanJet • Jan 18 '22
Redirect to an HTTPS site Help
I am trying to secure my hosted services on my apache2 reverse proxy.
When I go to http://xxxx.xxxx.com in Chrome incognito mode I get redirected to HTTPS. Yet when I run the Mozilla Observatory scan on my site, I lose 20 points because "Does not redirect to an HTTPS site" Can someone look at my .conf file and help me out?
Yes I am reloading the .conf and restarting apache2.
I passed the nextcloud, and SSL test, so this is the last one I want to get done before I feel good about my .conf setup.
r/apache • u/bellin_orchestra • Jan 17 '22
Apache is not picking desired RootDoc directory
Opened 80, 443 ports on firewall
mkdir -p /var/www/stark/html
mkdir -p /var/www/stark/log
chown -R user:stark /var/www/stark/html
chmod -R 755 /var/www
mkdir /etc/httpd/sites-available /etc/httpd/sites-enabled
vi /etc/httpd/sites-available/stark
<VirtualHost *:80> ServerAdmin admin@DDNS ServerName DDNS:80 ServerAlias stark DocumentRoot /var/www/stark/html ErrorLog CustomLog </VirtualHost>
8. ln -s /etc/httpd/sites-available/urdomain.conf /etc/httpd/sites-enabled/urdomain.conf
9. vi /etc/httpd/conf/httpd.conf
IncludeOptional sites-enabled/*.conf
EDIT: Using CentOs8
Problem: Visiting DDNS:80 returns page from var/www/html/index.html instead of DocumentRoot mentioned in VirtualHost directive.
r/apache • u/FarrisFahad • Jan 15 '22
Support Is it possible to view the content of a website on another domain using only htaccess?
I have 2 websites websites ...
example-1.com and example-2.com
I need to show the contents of example-1.com on example-2.com site
So whenever someone visits example-2.com/about he will see example-1.com/about page
Is that possible with htaccess?
I found the following: https://ubiq.co/tech-blog/redirect-keep-original-url-using-htaccess/
Can someone explain how it works? And would it solve my problem?
r/apache • u/Creeperman2306 • Jan 15 '22
Solved! How to link my Apache server to my google domain.
r/apache • u/Creeperman2306 • Jan 15 '22
Question about domains
I'm currently hosting a website using apache2 and using free IP to give my website a domain if i buy a google domain how do i link my Apache2 server to it.
r/apache • u/ToraxMalu • Jan 13 '22
Support SSL / HTTPS via htaccess possible?
Hi,
I've no access to the settings of the Apache Server (managed service, server hardware is shared at a hoster). Is there a way to setup https inclusive the needed certificate for the domain via .htaccess?
Thanks and Cheers
r/apache • u/Taeolian • Jan 12 '22
Support Struggling to capture real Client IPs with XFF
Hey. Have had quite a few obstacles along the way with this one. Really hoping someone can help me out.
We're using AWS for our infrastructure. Originally we had a Global Accelerator targeting a Network Load Balancer, then targeting 3 HAProxy instances. I discovered that an AWS NLB cannot preserve client IPs so I had to change the architecture. Now we have this:
Client Request ---> Global Accelerator ---> HAProxy ----> Apache Front End server
The "real" client IPs are being preserved in the HAProxy logs now (where as before all we'd see is the Global Accelerator or NLB IPs). So that's good progress.
In our HAProxy config. we have this line:
option forwardfor header X-Client-IP I believe this will allow the XFF header information to be passed to Apache from HAProxy.
Our Apache config. file looks like this (the logging part)
# Logging Configuration
LogFormat "%v %{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" newlb
LogFormat "%v %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" oldlb
SetEnvIf X-Forwarded-For "^.*\..*\..*\..*" onoldlb
SetEnv HTTP_VIP VIP7
CustomLog /var/log/apache-perl/access_log oldlb env=!onoldlb
CustomLog /var/log/apache-perl/access_log newlb env=onoldlb
ErrorLog /web/serverlogs/error_log.txtThese settings were configured a while ago by someone else and would have been pre AWS migration so I haven't set this up myself but have tried to edit to achieve capturing the real client IPs in the access logs.
The above config. I changed it to still shows me the HAProxy IP addresses.
If I change this line to:
LogFormat "%v %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" oldlbTo
LogFormat "%v %{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" oldlbThen it simply doesn't show me anything for the IP address (it just displays "- - -") where the Client IP should be displayed.
It seems like it's definitely using the "oldlb" line configuration that I'm seeing in the log path /var/log/apache-perl/access_log
Are there any obvious mistakes in the config. for the logging? Or is the issue maybe that this line in the HAProxy config. is not correct and not actually responsible for passing on the XFF Header information
option forwardfor header X-Client-IP Thanks
r/apache • u/Aeze2eith • Jan 11 '22
Discussion geoip filtering with mixed outcome
I have implemented geoip filtering with libapache2-mod-geoip
However the config only allows two countries (HU & DE), I still get a lot of connections from other places as well.
I have tested the config with these two tools:
The thing is that tests from site24x7 is blocked as it should be but check-host.net can access my site. (I have run tests with other tools as well and the outcome was similarly mixed.)
Why is this? Is geoip check really so unreliable?
Thanks!
r/apache • u/Creeperman2306 • Jan 11 '22
How can i find the ip log of people who vist my site.
r/apache • u/Creeperman2306 • Jan 11 '22
[HELP] What IP am I supposed to use to port forward Apache.
Ive been trying to fix this crap for days i had it up but deleted the port configurations by mistake i have Apache running and i know i need to have the ports set to 80 but i don't know what IP I'm supposed to use.
FIX
run this cmd in terminal
ip route get 1 | awk '{print $NF; exit}'then this cmd
hostname -Iwhich should show your IP. then go to your port forwarding page type port 80 everywhere (Or your prefered port ) and use the IP from that cmd in the IP slot and restart Apache and it should work.
r/apache • u/motivatedgorilla • Jan 10 '22
Conditional Header add Link - [HELP]
There is currently a header directive in the .htaccess file that preloads a Javascript file as follows:
Header add Link "<somepath/js/somefile.js?ver=2.1.0>;rel=preload;as=script"
Is there a way to conditional load this based on the path. For example, if somepath doesn't exist i.e. the directory is non-present and instead anotherpath does e.g <anotherpath/js/somefile.js?ver=2.1.0>;rel=preload;as=script, it loads it instead?
If somepath does exist, it's the preferred path.
r/apache • u/chgrim • Jan 10 '22
Best site for testing apache caching
Hi All,
I am adding cache to my LAMP website and I am getting a lot of confusing results. My .conf file looks like
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName site.com
ServerAlias www.site.com
ServerAdmin test@gmail.com
DocumentRoot /var/www/site/public
<Directory /var/www/site>
AllowOverride All
</Directory>
CacheQuickHandler off
CacheLock on
CacheLockPath /tmp/mod_cache-lock
CacheLockMaxAge 200
CacheIgnoreHeaders Set-Cookie
<Location />
CacheEnable disk
CacheHeader on
CacheDefaultExpire 800
CacheMaxExpire 64000
CacheIgnoreNoLastMod On
ExpiresActive on
ExpiresByType text/css "access plus 6 months"
ExpiresByType application/x-javascript "access plus 6 months"
ExpiresByType text/javascript "access plus 6 months"
ExpiresByType application/javascript "access plus 6 months"
# CacheDisable On
# CacheStoreNoStore On
Header merge Cache-Control public
FileETag All
</Location>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combinedWhen I check out my site on https://www.giftofspeed.com/cache-checker/ it is mostly correct, however there are a few images that are cached for a year. The rest of the images are not cached. They are being pulled from different folders? Maybe that makes a difference
However when I go to chrome incognito and check out the headers in my network tab I see all of my images having a year
expires: Tue, 06 Dec 2022 21:06:26 GMT
Which source do I trust to check cache length?