我尝试在我的ubuntu服务器上使用apache代理,以便在不使用端口的情况下访问我的node.js应用程序,但我测试过的解决方案都不起作用。
基本上,我有一个网站在我的域名examle.com上运行,并希望使用myapp.example.com这样的子域或使用example.com/myapp之类的东西来访问node.js应用程序(在端口3000上运行并使用https)
以下是我当前的conf文件(不工作):
#mainWebsite
<VirtualHost example.com:443>
# Admin email, Server Name (domain name), and any aliases
ServerAdmin [email protected]
ServerName example.com
ServerAlias www.example.com
#Redirect
#Directory
<Directory "/var/www/html/example.com">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
# Index file and Document Root (where the public files are located)
DirectoryIndex index.html index.php
DocumentRoot /var/www/html/example.com/public_html
# Log file locations
LogLevel warn
ErrorLog /var/www/html/example.com/log/error.log
CustomLog /var/www/html/example.com/log/access.log combined
# Error Docs
ErrorDocument 404 /www/html/example.com/errorDocs/404.html
ErrorDocument 503 /www/html/example.com/errorDocs/503.html
# SSL
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
#node.js app
<VirtualHost myapp.example.com:433>
# Admin email, Server Name (domain name), and any aliases
ServerAdmin [email protected]
ServerName myapp.example.com
ServerAlias www.myapp.example.com
# Proxy
ProxyRequests Off
ProxyPreserveHost On
ProxyVia Full
<Proxy *>
Require all granted
</Proxy>
<Location /nodejs>
ProxyPass https://127.0.0.1:3000
ProxyPassReverse https://127.0.0.1:3000
</Location>
# Log file locations
LogLevel warn
ErrorLog /var/www/html/example.com/log/error.log
CustomLog /var/www/html/example.com/acces.log combined
# Error Docs
ErrorDocument 404 /www/html/example.com/errorDocs/404.html
ErrorDocument 503 /www/html/example.com/errorDocs/503.html
#SSL
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>```
By the way if someone could help me, why my error Docs don't show up, I would be very happy :)
字符串
1条答案
按热度按时间t98cgbkg1#
下面是我的配置文件,我在Ubuntu的Apache webs-server中使用子域。
字符串
您可以在 * https://myapp.example.com * 这样的子域中访问节点应用程序
子目录托管可以尝试以下配置:
型
您可以通过类似于***https://example.com/myapp***的方式访问节点应用程序