Skip to content

Instantly share code, notes, and snippets.

@koenpunt
Created October 4, 2012 16:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koenpunt/3834852 to your computer and use it in GitHub Desktop.
Save koenpunt/3834852 to your computer and use it in GitHub Desktop.
Using Nginx as SSL Proxy for Name Based VirtualHosts in Apache
server {
listen 443 ssl;
server_name ~^(www\.)?(?<domain>.+)$;
# It's possible to configure Nginx to serve static files directly, and
# bypassing Apache but I won't describe that here.
root /var/apps/$domain/current/public;
ssl_certificate /etc/ssl/certs/cmpgns/STAR_cmpgns_nl.crt;
ssl_certificate_key /etc/ssl/private/STAR_cmpgns_nl.key;
location / {
# Apache is listening here
proxy_pass http://127.0.0.1:80;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# Set HTTPS flag for mod_rpaf
proxy_set_header X-Forwarded-HTTPS on;
}
}
RPAF_Enable On
RPAF_ProxyIPs 127.0.0.1
RPAF_SetHostName On
RPAF_SetHTTPS On
RPAF_SetPort On
<VirtualHost 127.0.0.1:80>
ServerName some-subdomain.cmpgns.nl
DocumentRoot "/var/apps/some-subdomain.cmpgns.nl/current/public"
RewriteEngine on
<Directory "/var/apps/some-subdomain.cmpgns.nl/current/public">
Allow from all
</Directory>
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment