Laravel & Nuxt hosted on vps - same domain how to access laravel storage and api?


I would like to host my nuxt app which has a Laravel backend on my VPS. I have done it and it works but when I have my .conf file for domain setup like this:

    <IfModule mod_ssl.c>
<VirtualHost *:80>
ServerName xxxxxxxxx
Redirect permanent / https://xxxxxxxxx/
<VirtualHost *:443>
    ServerName xxxxxxxxx
    ServerAlias www.xxxxxxxxx
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www/htmlxxxxxxxxx/public

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    # has Nuxt runs on port 3000
    ProxyPass / http://localhost:3000/
    ProxyPassReverse / http://localhost:3000/
    RewriteEngine on

    <Directory /var/www/html/xxxxxxxxx/public/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/livexxxxxxxxx-0001/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/xxxxxxxxx-0001/privkey.pem

The nuxt app works and server-side rendering is enabled but none of my api calls on my domain work.

That could be solved by api subdomain but how can I access my laravel files stored in /storage?

I have run php artisan storage:link but I cannot get the files to show because the nuxt server is I believe kill request to the laravel part.

Can anybody help, please?

Thank you.

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi there,

Indeed one option is to setup the Laravel application on a subdomain name for example:

That way the two applications will be separate and would have separate Apache virtual hosts.

Another option is to setup an alias for your Laravel application inside the Apache Vhost that you shared:

     Alias /app /var/www/laravel/public

That way your Laravel appliation would be accessible at

Note that you will also need to change your Laravel APP_URL to APP_URL= and if you have an .htaccess file you will need to change the following:

// ...
RewriteEngine On

# Add this line
RewriteBase /app/
// ...

Hope that this helps! Regards, Bobby