Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ramonsenadev/e38317ea4793fb9aa3ce70a18ef1e42c to your computer and use it in GitHub Desktop.
Save ramonsenadev/e38317ea4793fb9aa3ce70a18ef1e42c to your computer and use it in GitHub Desktop.
Using apache as a reverse proxy with Nuxt

Apache Config

  1. Enable the following modules (Remove the # on beginning of the line) in xampp/apache/conf/httpd.conf
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
  1. Copy and paste the bellow code, and edit the lines with "[EDIT]" xampp/apache/conf/extra/httpd-vhosts.conf
<IfModule mod_proxy.c>
	<VirtualHost *:80>
		ServerName domain.localhost [EDIT]
		ServerAlias WWW.domain.localhost [EDIT]
	
		DocumentRoot "C:/Users/Ramon/xampp/htdocs/project/public" [EDIT]
		<Directory "C:/Users/Ramon/xampp/htdocs/project/public"> [EDIT]
			Options +Indexes +Includes +FollowSymLinks +MultiViews
			AllowOverride All
			Require local
		</Directory>
  
		ProxyRequests On
		<Proxy>
			Order deny,allow
			Allow from all
		</Proxy>
		ProxyVia On
		ProxyPassMatch ^(?:(?!\/dev\/).)*\.(?:ico|gif|jpe?g|png|woff2?|eot|otf|ttf|svg|js|css)$ !
		ProxyPass / http://127.0.0.1:3000/
		ProxyPassReverse / http://127.0.0.1:3000/
		ProxyPreserveHost On
		Header set Access-Control-Allow-Origin "*"
		Header set Access-Control-Allow-Methods "GET
	</VirtualHost>
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment