How to handle virtual aliases when only the %u is stored in LDAP - ldap

Here's the relevant part of the config:
maildrop_destination_recipient_limit = 1
#virtual_mailbox_domains = new.example.com example.com www.example.com mail.example.com imap.example.com virtual.example.com
virtual_mailbox_maps = ldap:/usr/pkg/et/postfix/ldap-aliases.cf
virtual_transport = maildrop
virtual_alias_maps = ldap:/usr/pkg/etc/postfix/ldap-aliases.cf
virtual_alias_domains = new.example.com example.com www.example.com mail.example.com imap.example.com virtual.example.com
ldap-aliases.cf
server_host = a.b.c.d
search_base = dc=example, dc=com
query_filter = mailalias=%u
result_attribute = mail
I have a somewhat strange setup and I'm trying to figure out if it's possible to do what I want. I'm using virutal hosting with (almost) all lookups taking place via ldap. The exception is that the domains the server accepts mail for are listed in the config file (see above).
The strange part is that in LDAP only the %u part is stored in the user record, in a custom field, mailalias. So for exmaple, I have:
mailalias: postmaster
mailalias: security
...etc
for me, as I'm the admin.
The ldap-aliases.cf works as a virtual alias, but it maps postmaster#anything.tld (which is obviously not what I want). I thought the alias domains would limit the aliases to only the example.com tlds listed.
Is there a way to keep the %u part in ldap and limit virtual_alias_maps to only match if the domain is one of the *.example.com ones listed?
Thanks in advance,
Jason M.

I almost had it. I tried domain_name = example.com new.example.com, etc. in ldap-aliases.cf but that didn't do it. But domain = example.com new.example.com, etc. in the ldap_aliases works. The lines that changed are:
virtual_mailbox_maps = ldap:/usr/pkg/etc/postfix/ldap-mailbox.cf<br>
virtual_alias_maps = ldap:/usr/pkg/etc/postfix/ldap-aliases.cf<br>
ldap-aliases.cf
server_host = a.b.c.d
search_base = dc=example, dc=com
domain = example.com new.example.com www.example.com virtual.example.com
query_filter = mailalias=%u
result_attribute = mail
ldap-mailbox.cf is the same as the original ldap-aliases.cf:
ldap-mailbox.cf
server_host = a.b.c.d
search_base = dc=example, dc=com
query_filter = mailalias=%u
result_attribute = mail
I wonder if I could use the ldap-aliases for the virtual_mailbox_maps? Or if I could use a hash:/ inside the ldap-aliases.cf?

Related

Bitnami on Google Cloud Platform enabling SSL Issue: Please fix DNS entries while enabling SSL

I am using the bitnami django on Google Cloud platform stack.
Goal: I want SSL configured on my bitnami stack hosted on Google Cloud. But their toolsudo ./bncert-tool complains "The domain resolves to a different IP address than the one detected for this machine. Please fix its DNS entries or remove it.
I have purchased a domain using google domains.
I have set up google dns to point to the IP address as I see in the bitnami stack. I have enabled mydomain.com and www.mydomain.com to forward to the cloud server ipaddress/home in Google domain name settings
I then tried to run the tool /opt/bitnami/bncert-tool:
sudo /opt/bitnami/bncert-tool
Welcome to the Bitnami HTTPS Configuration tool.
Domains
Please provide a valid space-separated list of domains for which you wish to
configure your web server.
Domain list []: mydomain.com
The following domains were not included: www.mydomain.com. Do you want to add them? [Y/n]: n
Warning: No www domains (e.g. www.example.com) or non-www domains (e.g.
www.example.com) have been provided, so the following redirections will be
disabled: non-www to www, www to non-www.
Press [Enter] to continue:
Warning: The domain 'mydomain.com' resolves to a different IP address than the
one detected for this machine, which is 'aa.bb.ccc.dddd'. Please fix its DNS
entries or remove it. For more info see:
https://docs.bitnami.com/general/faq/configuration/configure-custom-domain/
Press [Enter] to continue:
MY QUESTION:
How do I resolve this? I even tried adding both domains
mydomain.com www.mydomain.com
I want SSL enabled for mydomain.com and www.mydomain.com and not sure where I am going wrong?
Secondy, after the link forwards, how to associate my domain name so that the static IP doesn't keep displaying instead it shows the mapped domain mydomain.com/home
thanks
Suds
$nslookup mydomain
Server: 192.168.0.1
Address: 192.168.0.1#53
Non-authoritative answer:
Name: mydomain.com
Address: 216.239.32.21
Name: mydomain.com
Address: 216.239.34.21
Name: mydomain.com
Address: 216.239.36.21
Name: mydomain.com
Address: 216.239.38.21
$ nslookup www.mydomain.com
Server: 192.168.0.1
Address: 192.168.0.1#53
Non-authoritative answer:
www.mydomain.com canonical name = ghs.googlehosted.com.
Name: ghs.googlehosted.com
Address: 172.217.26.179
$ dig +short NS mydomain.com ns-cloud-b1.googledomains.com.
ns-cloud-b2.googledomains.com. ns-cloud-b3.googledomains.com.
ns-cloud-b4.googledomains.com.
$ dig +short NS www.mydomain.com ghs.googlehosted.com.
You may need to change certain settings such as the domain name settings. If using Google Domains, the forwards actually don't integrate the A + Cname to one static IP. I had to physically create A and CName records.
This solved the first issue: What is interesting is one of my domains: mydomain.com is pointing multiple IP address whereas the other is point to different IP depending upon the DNS Server. This was also the one contributing to the error I used to get
when I ran sudo ./bncert-tool "The domain 'mydomain.com' resolves to a different IP address than the one detected for this machine, which is 'aa.bb.ccc.ddd'. Please fix its DNS entries or remove it.
I think physically forced the HTTPS redirection in web server settings. using this rule
/opt/bitnami/apache2/conf/bitnami/bitnami.conf,
Changed RewriteRule ^/(.*) https://example.com/$1 [R,L]
Then I still had some problems where the first hit the URLs will load, the next hit I would 404 errors.
I realized this was an issue with project level settings
opt/bitnami/apps/django/django_projects/Project/conf
sudo vi httpd-app.conf
WSGIScriptAlias /PROJECT '/opt/bitnami/apps/django/django_projects/PROJECT/PROJECT/wsgi.py'
to
WSGIScriptAlias / '/opt/bitnami/apps/django/django_projects/myproject/myproject/wsgi.py'
Then was the issue with ALLOWED HOSTS in settings.py:
Ensure the right ALLOWED HOSTS is updated, the project root or your application root, depending upon where you serve from.
/opt/bitnami/apps/django/django_projects/Project/Project
updated the settings in py here...
ALLOWED_HOSTS in settings.py

Redirect to another server site without changing domain name

I have two servers running Apache2, one with an associated domain name, let's say "www.home.com" and another one only known by its IP address, let's say 10.11.12.13.
On www.home.com I have three web sites, configured through aliases in apache.
I have http://www.home.com, http://www.home.com/school, http://www.home.com/work.
All these sites are on the server www.home.com.
On 10.11.12.13, I have only one site, accessible by http://10.11.12.13/wiki
How can I configure apache to have http://www.home.com/wiki working but transparently (not changing URL) call http://10.11.12.13/wiki site ?
In other words, the user shall only see www.home.com/wiki/xxxxx when he uses the wiki.
What I have done:
On www.home.com : i have added a wiki folder with nothing in it, and an alias for www.home.com/wiki to work properly.
Then I have tried to use mod rewrite to replace 10.11.12.13 by www.home.com but that does not work, and I am not even sure to do it the right way.
For your information, mod rewrite is configured and works properly on both servers.
Someone could please help me on that ?
Maybe mod rewrite is not the right solution ?
Thanks !
Sam
I finally found a solution : the mod_proxy along with tags.
The conf that worked for me:
<VirtualHost *:80>
[...]
ServerName www.home.com
<Location /wiki>
Allow from all
ProxyPass "http://10.11.12.13/wiki"
ProxyPassReverse "http://10.11.12.13/wiki"
</Location>
</VirtualHost>

Masking a forwarding domain with no webspace for the domain to show

I have a webspace on my own domain – let's call it my-domain.com. I'm hosting my friends website – let's call her Alice – on my webspaces subfolder alice which is therefore reachable under my-domain.com/alice.
My friend Alice decides to buy herself a Domain with Forwarding (but without webspace) and forwards it to the my-domain.com/alice URL. The forwarding is working but she wants the URL in the browser to look like it was hosted on her own webspace, e.g. like so: alices-domain.com/start.html (instead of what it looks like right now: my-domain.com/alice/start.html).
I found ways to mask a domain when one has success to the domains webspace (e.g. via mod_rewrite) – but there is no webspace in this case where I could put a .htaccess file in (just my own webspace).
Is there a way I can still achieve masking without buying a new webspace for the domain?
If you just copied files to a sub folder then you will need to set it up as a virtual host in your apache config file so that your server will know where to go when you type in her domain name. Vhosts are usually towards the bottom of the file. In centos it should be httpd.conf or ubuntu apache2.conf I believe.
Then just create another section for Alice's site.
e.g.
<VirtualHost *:80>
ServerAdmin webmaster#alices-domain.com
DocumentRoot /var/www/path/to/alices/folder/
ServerName www.alices-domain.com
ServerAlias alices-domain.com
ErrorLog /var/www/alices-domain.com/error.log
CustomLog /var/www/alices-domain.com/requests.log
</VirtualHost>
Remove the forwarding on Alice's domain and then point Alice's DNS main A record to your servers IP address.
UPDATE:
To be clear and answer your last question.
Create a subdomain like alice.yousite.com which will have a document root of htdocs/alice.
Now go to the DNS records for www.alice-site.com and add a CNAME. The host value will be www and then points to (value) alice.yoursite.com.
So when that propagates, you can go to www.alice-site.com and it will display alice.yoursite.com.

CNAME address in apache configuration

I have MULTIPLE domain to map my server's subdomain. For example
www.xyz.com -> goo.myserverdomain.com
www.lmn.com -> fb.myserverdomain.com
www.abc.com -> twt.myserverdomain.com
I do the mapping using CNAME in each domain. Now at my server end, I want to resolve my server subdomain. So i want to configure like
ServerName myserverdomain.com
ServerAlias *.myserverdomain.com
ProxyPass / http://<IP>:8780/(goo/fb/twt ...)
When I do the configuration, apache do not recognize the virtual host and show the first default one. I seems that i am getting host name. How to resolve myserverdomain address in my configuration. Please help
It does not matter how the domain mapping is done. Apache does not know this and also the web browser does not care. It simply reacts on the line "Host:" send in header.
To enable virtual name solving, you need to set
NameVirtualHost ...
for each IP+port combination or with '*' for all.
Usually when starting, Apache will tell you that you have virtual hosts, but no proper name switching.

help regarding setting up pseudo/fake subdomains on apache

First of all, sorry if I got the term 'pseudo subdomain' wrong.
what I am trying to achieve is this-
When someone registers on my application, they get a new url like..
yourname.myapp.tld
I dont want to use the subdomain system for this. To be frank, I dont know how the subdomains exactly work but it guess it requires a folder per subdomain inside the document root and then the server redirects the requests there.
Can this be achieved by doing something like -
when a visiter types any subdomain, (anything.myapp.tld), he is able to access myapp . In the index.php file i will explode the $_SERVER['HTTP_HOST'] to get the subdomain which i will store in session and will thereafter act as an identifier for that user. Ideally i wouldnt want to create any vhosts or add many lines to the hosts file. Can this be achieved with just one vhost?
Is this possible with mod rewrite or something ?
Yes you can archive this using wildcard that needs to be configured on both, the dns server and http server
On the dns a entry like this (installing dns on ubuntu https://help.ubuntu.com/10.04/serverguide/C/dns.html):
; wildcard subdomains are all directed to this IP
; of course this should be the IP of your web server
*.domain.tld. IN A 1.2.3.4
At apache an entry like this:
<VirtualHost 111.22.33.55>
DocumentRoot /www/subdomain
ServerName www.domain.tld
ServerAlias *.domain.tld
</VirtualHost>
What happens after is that everything.domain.tld will be going to your main folder so you can use the index.php to redirect it to the right place or even an htaccess using mod_rewrite.