Deploy PWA Magento 2 app to production on apache
Posted date: Jun 24, 2022
Configure proxy vhosts
You need to create a vhosts configurations
sudo nano /etc/apache2/sites-available/pwa-app.conf
and then paste these configurations.
<VirtualHost *:443>
ServerName my-pwa.com #(links to pwa project root folder)
ServerAlias my-pwa.com #(links to pwa project root folder)
ProxyPreserveHost On
ProxyRequests Off
ProxyPass /https://my-pwa-hcxix.com:9000/ #your upward url
ProxyPassReverse /https://my-pwa-hcxix.com.pwadev:9000/ #your upward url
SSLProxyEngine on
SSLProxyVerify none
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
SSLProxyCheckPeerExpire off
SSLEngine on
SSLCertificateFile /path/to/key.crt
SSLCertificateKeyFile /path/to/key.key
</VirtualHost>
Start the server
sudo yarn build
sudo yarn start & # using & runs in background
Your magento 2 pwa app now should be accessible by this urlmy-pwa.com
Additional notes
You might need to run this command first in your pwa root folder to acquire custom hostname, ssl, development and staging port for your app.
yarn run buildpack create-custom-origin .