Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
333 views
in Technique[技术] by (71.8m points)

macos - Apache: can't access css files in virtual host subdirectory

I am using apache to setup a virtualhost for my two angular projects, i wanted one of them to be in a subdirectory of the main host, after setup the apache and everything, i changed my httpdvhost.conf file and it looks like this right now:

<VirtualHost *:80>
    ServerName http://local.example.com
    ProxyPass /chat http://localhost:8100
    ProxyPassReverse /chat http://localhost:8100
    ProxyPass / http://localhost:4200/
    ProxyPassReverse / http://localhost:4200/
</VirtualHost>

My problem is that my project at port 8100 can't get it's css files as it looks for main.css for example at the path http://local.example.com/build/main.css instead of looking for it in the path http://local.example.com/chat/build/main.css.

is there any solution for that ? I am a total beginner in this area so i can't find one.

question from:https://stackoverflow.com/questions/65901569/apache-cant-access-css-files-in-virtual-host-subdirectory

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

According to the documentation http://httpd.apache.org/docs/2.4/mod/mod_proxy.html#proxypass your configuration seems to be correct except for a "/". Change your configuration as following:

<VirtualHost *:80>
    ServerName http://local.example.com

    ProxyPass /chat/ http://localhost:8100/
    ProxyPassReverse /chat/ http://localhost:8100/

    ProxyPass / http://localhost:4200/
    ProxyPassReverse / http://localhost:4200/
</VirtualHost>

moreover add some logging to the virtualhost to find out what's happening: https://httpd.apache.org/docs/2.4/logs.html.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...