dongpian2559 2019-05-07 04:31
浏览 185
已采纳

如何将apache服务器配置为http:// localhost:3000 /并排除某些URL?

I want my Laravel to use Client side Nuxt JS and use Laravel as backend admin-panel and api(s).

This is my code to proxy Laravel project to Nuxt JS but it's not properly working.

<VirtualHost *:80>
    ServerName nuxt.local

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/nuxt/public

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

    ProxyPassMatch /^(admin-panel)(.*)$ !

    ProxyPass / http://localhost:3000/
    ProxyPassReverse / http://localhost:3000/
    ProxyPreserveHost on
    LogLevel debug
 </VirtualHost>

I want to exclude "admin-panel" and "api" routes from hitting the proxy.

  • 写回答

3条回答 默认 最新

  • dtb81443 2019-05-15 05:00
    关注

    I have solved the problem

    I am posting my apache2 config code. Might be this can be helpful for any.

    <VirtualHost *:80>
    
      ServerName blog.net
    
      ServerAdmin webmaster@localhost
      DocumentRoot /var/www/html/blog/public
    
      <LocationMatch "/"> 
        allow from all 
        Satisfy any 
        ProxyPass http://localhost:3000/
        ProxyPassReverse http://localhost:3000/
      </LocationMatch>
    
      <LocationMatch "/admin-panel/*"> 
        allow from all 
        Satisfy any 
        ProxyPass http://localhost/blog/public
        ProxyPassReverse http://localhost/blog/public
      </LocationMatch>
    
      <LocationMatch "/admin/*"> 
        allow from all 
        Satisfy any 
        ProxyPass http://localhost/blog/public
        ProxyPassReverse http://localhost/blog/public
      </LocationMatch>
    
      <LocationMatch "/api/*"> 
        allow from all 
        Satisfy any 
        ProxyPass http://localhost/blog/public
        ProxyPassReverse http://localhost/blog/public
      </LocationMatch>
    
      ErrorLog ${APACHE_LOG_DIR}/error.log
      CustomLog ${APACHE_LOG_DIR}/access.log combined
    
    </VirtualHost>
    

    and in laravel routes/web.php file write the

    \URL::forceRootUrl(env('APP_URL'));
    

    to use project URL not proxy URL

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?