I have been trying to solve this issue for the past days, but haven't been able to fix it. The problem is that my domain name redirects me to my static ip address, but as soon as the page is loaded, the url displays the ip.
Some context:
I am running a django-based application in AWS Lightsail, which uses Apache 2 as the web-server. I have created a virtual host that serves port 80.
The domain name I bought it using GoDaddy, and currently points to this static ip. My intuition tells me that the problem is not with the domain service provider because it does redirect my traffic to the ip. However, one thing to consider is that I have not changed the nameservers at Godaddy, would this be the root problem?
My httpd.conf file looks like this, in AWS is named bitnami.conf:
<VirtualHost _default_:80>
WSGIScriptAlias / /opt/bitnami/apps/django/django_projects/myApp/myApp/wsgi.py
ServerName myApp.ca
<Directory /opt/bitnami/apps/django/django_projects/myApp>
AllowOverride all
Require all
grantedOptions FollowSymlinks
</Directory>
DocumentRoot /opt/bitnami/apps/django/django_projects/myApp
Alias /static/ /opt/bitnami/apps/django/django_projects/myApp/static/
<Directory /opt/bitnami/apps/django/django_projects/inVerte/static>
Require all granted
</Directory>
</VirtualHost>
I have tried adding other directives such as:
RedirectPermanent / http://myApp.ca/
Redirect /index http://myApp.ca/
RewriteEngine On
RewriteCond %{HTTP_HOST} !^myApp.ca$
RewriteRule /.* http:/myApp.ca/ [R]
However, they only cause a 502 error.
I tried running this command curl -I "mydomain.com".
Output:
HTTP/1.1 301 Moved Permanently
Server: nginx/1.16.1
Date: Wed, 05 Aug 2020 21:42:24 GMT
Content-Type: text/html; charset=utf-8
Connection: close
I tried using "sudo /opt/bitnami/ctlscript.sh status"
Output:
apache already running
mysql already running
postgresql already running
The last thing I have done: I updated the A record in my DNS settings at Godaddy, so I made sure that the domain name is translated to the IP. Moreover, I have configured forwarding with masking. However, this lead me to the following error when visiting the site:
Website will not allow Firefox to display the page if another site has embedded it
https://support.mozilla.org/en-US/kb/xframe-neterror-page?as=u&utm_source=inproduct
Related
I have two local Domain which work fine, however, the otherA domain is the API server that the otherB domain consumes API. The problem is it can't access the otherA domain, and returns network error something like
option 1
let apiserver = 'http://localserverA.local'
axios.get(`${apiserver}/apicall`).....
catch( ---> return network error
But this works
option 2
let apiserver = 'http://127.0.0.1:8000'
axios.get(`${apiserver}/apicall`).....
returns 200 ok
The problem with option 2 is to run php built in server which not a good idea because some set up in databases requires domain local host to access its data.
<VirtualHost *:80>
ServerName localserverA.local
ServerAlias localserverA.local
DocumentRoot C:/projects/r/projects/A/web
<Directory "C:/projects/r/projects/A/web">
AllowOverride All
Require all granted
Allow from All
Allow from 127.0.0.1
Allow from ::1
#FallbackResource /app.php
</Directory>
</VirtualHost>
I can even ping my domain name, it works well in browser but got network error when endpoint called via javascript. Works well in production
Any Idea?
This may help you:
Go to directory (from where your landing page load, if you have laravel project you need to go to public directory) to your project in command promt and fire command.
php -S <ip addresss>: <any port no>
like this
php -S 192.168.1.62:4200
Now you can access that project using 192.168.1.62:4200
You need to change your %SystemRoot%\system32\drivers\etc\hosts file. Add next line:
127.0.0.1 localserverA.local
I have a CentOS 7 server with about 20 domains all managed automatically with a vhosts file in /etc/httpd/conf.d.
I am trying to learn Django and wanted to set up a single domain using it, so I added a specific virtualhost to the .conf file.
The result is that the Django domain works fine but all the other sites are broken (try to use Django but cause errors).
The Django domain has two folders: djangodomain.com for static files and djangodomain.app for the Python files.
How can I integrate a single Django domain into my existing many-domain virtual host setup?
Existing vhosts.conf:
<VirtualHost *:80>
serveradmin username#domain.com
serveradmin username#domain.com
usecanonicalname off
# www.site.com ยป site.com
rewriteengine on
rewritecond %{HTTP_HOST} ^www\.(.*)$ [nc]
rewriterule ^(.*)$ http://%1 [r=301,l]
# file locations
virtualdocumentroot "/home/username/%0"
<directory "/home/username/*">
allowoverride all
require all granted
options indexes followsymlinks
options +execcgi
options +includes
</directory>
</VirtualHost>
What I added that broke all but the Django site:
<VirtualHost djangodomain.com:80>
ServerName djangodomain.com
ServerAlias www.djangodomain.com
ServerAdmin user#domain.com
DocumentRoot /home/username/djangodomain.com
WSGIScriptAlias / /home/username/djangodomain.app/django.wsgi
<Directory /home/username/djangodomain.app>
Order allow,deny
Allow from all
</Directory>
Alias /robots.txt /home/username/djangodomain.com/robots.txt
Alias /favicon.ico /home/username/djangodomain.com/favicon.ico
Alias /images /home/username/djangodomain.com/images
Alias /static /home/username/djangodomain.com/static
ErrorLog /home/username/djangodomain.logs/error.log
CustomLog /home/username/djangodomain.logs/access.log combined
</VirtualHost>
Crossposted to unix.stackexchange.com
When Apache gets an HTTP request, it needs to know what virtual host is supposed to process this request. Now, the way it works is. Apache picks up the IP address that the client request came into (the server IP, not the client) and it goes through the list of virtual host definitions to find any virtual hosts defined for that IP. If there is more than one, it will look at the Host header and try to match it to a particular ServerName or ServerAlias directive. If it still cannot find one, it will look for a default virtual host.
You have two virtual host definitions. One if the default vhost on port 80 <VirtualHost *:80>. It is the default because it has * for IP. The other is specific for the IP address <VirtualHost djangodomain.com:80>. The IP it uses is whatever djangodomain.com resolves to.
So any request that comes to that IP will be handled by the IP specific config before it might be allowed to drop into default.
To fix this, you need to replace your django virtual host directive with <VirtualHost *:80>, same as your other vhosts. This should put them all at the same parsing priority and it will just use the Host header to figure out the rest.
The said, if you are running a web server with 20+ vhosts, you really need to have better understanding on how it works. Read up on HTTP and web hosting when you have the time.
I have seen alot alot of guides how to fox the AH01630 error and some httpd corrections and tweaks.
Surely some will be annoyed me asking for help on this specific topic but I was trying to figure out for hours how to fix my issue.
What did I do?
I have port-forwarded the required ports for Apache and MySQL
I installed WAMP on my computer
I tried to config. httpd
I read about 50 topics according to make my server public accessible
-
I tried to set up the whole thing on a fresh virtual machine
I reinstalled WAMP a few times
So what doesn't work?
The usual access refuse message: Forbidden You don't have permission to access / on this server.
-I found this in the error log: AH01630: client denied by server configuration
I have tried to fix the issue by my own and couldn't proceed further after hours, maybe I forgot a little detail or just something I have to know but I don't because I am uneducated in this specific area
Thanks in advance
Here are the logs and config, if you don't mind and know how to fix the problem send me the finished file
httpd.conf
apache_error.log http:// pastebin. com/YSZDc0tp
access.log http:// pastebin. com/xfwv5ebB
In WAMPServer 3+ there is a Virtual Host defined for localhost by default, and that is where you should make the access amendments and not in httpd.conf
So in httpd.conf replace
# onlineoffline tag - don't remove
Require all granted
</Directory>
With
# onlineoffline tag - don't remove
Require local
</Directory>
Edit \wamp\bin\apache\apache\apache2.4.18\conf\extra\httpd-vhosts.conf and replace Require local with Require all granted
EG
#
# Virtual Hosts
#
<VirtualHost *:80>
ServerAdmin webmaster#homemail.net
ServerName localhost
DocumentRoot E:/wamp/www
<Directory "E:/wamp/www/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
I'm not sure if this is even possible, but if so I'm looking for the best way to do it.
Say I want to host my blog for example.com on it's own EC2 instance, and I want the path to my blog to be example.com/blog
Is it possible to route all requests to example.com/blog/* to one instance, and all other requests to that domain elsewhere?
My web server is Apache.
Thanks!
You can now do this with Application Load Balancer and path-based routing: https://docs.aws.amazon.com/elasticloadbalancing/latest/application/tutorial-application-load-balancer-cli.html#path-based-routing-aws-cli
Certainly it's possible, but not with DNS nor with an ELB. The most common solution to this is to use a web server that issues a 301 or 302 redirect.
In your case, example.com would point to whatever the main site is. The web server (nginx or Apache httpd, perhaps) hosting example.com would have a redirect for example.com/blog/* that is found at another destination.
Here's an SO post on using Nginx for a redirect and for using Apache for a redirect.
Yes, but you would have to proxy your requests through an instance handling example.com. How you configure this depends on your web server.
Some examples on how to configure this:
nginx: http://wiki.nginx.org/HttpProxyModule
Apache: http://httpd.apache.org/docs/2.2/mod/mod_proxy.html
Since you are using Apache2 Server, so you can achieve this very easily by creating a Virtual Host.
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/vchost1.com.conf
Create Virtual Configuration using the above command, it copies the complete code of content from the default file provided by the apache2 Server.
sudo nano /etc/apache2/sites-available/vchost1.com.conf
start configuring host & domain according to your requirements
<VirtualHost *:80>
ServerAdmin admin#domain.com
ServerName domain.com
ServerAlias www.domain.com
DocumentRoot /var/www/domain.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
here also, you can multiple Virtual Host configurations in a single file, start configuring and enjoy hacking.
you can also multiple web applications in a single instance by using the same method and theis reference.
https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-18-04-quickstart
I have found at least a dozen entries for this error even in this forum, and many outside. All are basically saying that inside <Directory></Directory>, I have "deny all" directive, and no "allow" directive.
I cannot write a fixed directory to match because it is created on the fly by a backend tomcat server.
When I entered "myUrl/test/request/user1/1234567890/download", I get
403 Forbidden: You don't have permission to access /test/request/user1/1234567890/download.
httpd error log shows:
[error] [client xxx.xx.xx.xxx] client denied by server configuration: /data/test, referer: myUrl/test/request/user1/1234567890
The part beginning with "test" is created by the backend tomcat, in which "user1" and "1234567890" vary, while the other parts of the directory structure remain fixed.
In my httpd.conf, I do have:
<VirtualHost *:80>
DocumentRoot /data
---
---
RewriteRule ^/test - [L]
---
</VirtualHost>
How do I solve this? Even if I create a different and create another document root, I will need a regex. Somewhere outside , I tried this:
<Directory "/data/test/request/*/*/download">
Options -Indexes -FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
But no success.
I am using "ajp" to talk to backend tomcat and have necessary module in place and I can telnet the backend tomcat server (on 8009) . So it should not be ajp communications problem.
The "test" piece in above url is actually a "context" inside /webapps directory of tomcat. Owner in that "test" context is tomcat, but I have added read permission for everyone.
First, I had to "deny all" for "/"
Directory
Deny from all
/Directory
Only then "Allow for all" for "/data"
Directory /data
---
---
Allow from all
/Directory
Then I rearranged RewriteRule, Redirect, ProxyPass, ProxyPassReverse inside the
VirtualHost *:80
/VirtualHost
and it worked!