Skip to content

Instantly share code, notes, and snippets.

@wuliupo
Last active January 19, 2017 08:18
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 wuliupo/773613f18155c9f50f9dbf48d18ff5e2 to your computer and use it in GitHub Desktop.
Save wuliupo/773613f18155c9f50f9dbf48d18ff5e2 to your computer and use it in GitHub Desktop.
ProxyPass dynamic html to Node.js by Apache
# Apache httpd config
# defined: Include conf/extra/local-www-httpd.conf;
# location: conf/extra/local-www-httpd.conf;
<VirtualHost www.test-local.com:80>
DocumentRoot D:/test-local
ServerName www.test-local.com
ServerAlias test-local.com
RewriteEngine on
RewriteCond %{HTTP_HOST} ^test-local.com/$ [NC]
RewriteRule ^(.*)$ http://www.test-local.com/$1 [R=301,L]
<Directory />
AllowOverride None
</Directory>
<Directory /test-local>
AllowOverride All
Require all granted
Options Indexes FollowSymLinks
</Directory>
ProxyPassMatch ^(/.*\.html)$ http://127.0.0.1:16003/$1
<Location "/">
Order deny,allow
Allow from all
</Location>
</VirtualHost>
# Nginx config
# defined: include vhost/*.conf;
# location: vhost/test-local.conf;
server {
listen 80;
server_name www.test-local.com test-local.com;
root D:\test-local;
index index.html;
if ($http_host !~ "^www.test-local.com$") {
rewrite ^(.*) http://www.test-local.com$1 permanent;
}
location / {
rewrite ^/$ /index.html last;
}
location ~* \.(html?)$ {
proxy_pass http://127.0.0.1:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
@wuliupo
Copy link
Author

wuliupo commented Jan 19, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment