Deploying a SvelteKit app on a VPS with apache2 - web-deployment

I've been trying to deploy a sveltekit app on my vps but it's not really working the home page is showing but when going on other url e.g http://weather.app.julesthibault.fr/test it's showing an apache error what did I do wrong ? This is the repository that I'm using : https://github.com/Julestblt/svelte-weather-app and this is my apache configuration :
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName weather.app.julesthibault.fr
ServerAlias weather.app.julesthibault.fr
DocumentRoot /var/www/svelte-weather-app/build/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =julesthibault.fr
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

Related

Point domain to IP

I created an apache server on Centos and configured the entire environment. I've already done the part of pointing the IP to the domain and even activated the SSL certificate (Lets Encrypt) and it worked, but some things are going wrong. For example, when I click on any link on the screen on my domain, the URL automatically goes to my IP instead of continuing on the domain. The same happens when I try to access domain.com/wp-admin, it is redirected to IP/wp-admin. I think it's some basic configuration but I'm a beginner in this part so if anyone can help I'll be grateful!
Vhosts:
<VirtualHost *:80>
ServerName mydomain.com
ServerAlias www.mydomain.com
DocumentRoot /var/www/html/wordpress
ErrorLog /var/www/example.com/log/error.log
CustomLog /var/www/example.com/log/requests.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.mydomain.com [OR]
RewriteCond %{SERVER_NAME} =mydomain.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
for default conf file (redirects all request to your domain with https):
<VirtualHost IP_ADDRESS:80>
Protocols h2 h2c http/1.1
ServerAdmin mail#example.com
Redirect permanent / https://example.com/
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
And for your domain conf file:
<VirtualHost example.com:80>
Protocols h2 http/1.1
RewriteEngine on
ServerName example.com
Redirect permanent / https://example.com/
</VirtualHost>
<VirtualHost example.com:443>
Protocols h2 h2c http/1.1
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/example.com/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/example.com/chain.pem
ServerName example.com
DocumentRoot /var/www/example.com
Alias / "/var/www/example.com/"
<Directory /var/www/example.com/>
Require all granted
AllowOverride All
Options FollowSymLinks MultiViews
<IfModule mod_dav.c>
Dav off
</IfModule>
</Directory>
<IfModule mod_headers.c>
Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains"
</IfModule>
</VirtualHost>

Stop localhost auto redirecting to https with the addition of www

Website configured on my localhost 'http://subdomain.customdomain.com' is redirecting to 'https://www.subdomain.customdomain.com' and I cant figure out why.
What I have done is the following:
Setup a hostname on dyn.com ie subdomain.dyndns.org
Setup router to update the dynamic IP to subdomain.dyndns.org on dyn.com (router is updating the IP correctly)
Since I want to use a custom domain added a CNAME record for subdomain.customdomain.com pointing to subdomain.dyndns.org (this is resolving to the correct IP)
Setup port forwarding on the port 80 on my router (external 80 to internal 80)
Setup virtual host on my local apache:
<VirtualHost subdomain.customdomain.com:80>
DocumentRoot "C:/xampp/htdocs/customdomain"
ServerName subdomain.customdomain.com:80
ServerAlias subdomain.customdomain.com:80
</VirtualHost>
Now when I open http://subdomain.customdomain.com in my browser it redirects to https://www.subdomain.customdomain.com with the error: This site can’t be reached www.subdomain.customdomain.com’s server IP address could not be found.
When I directly add subdomain.customdomain.com to point to my LAN IP in my windows host file, It does not redirect and website works fine.
Just cant figure out what is going wrong?
Below are the .htaccess file contents:
# BEGIN WordPress
# The directives (lines) between `BEGIN WordPress` and `END WordPress` are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
<FilesMatch "\.(?i:pdf)$">
ForceType application/pdf
Header set Content-Disposition attachment
</FilesMatch>
Fixed the issue! The issue was with the virtual host configurations.
The configuration which was causing the issue
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/"
ServerName localhost
ServerAlias localhost
<Directory "C:/xampp/htdocs/">
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost subdomain.customdomain.com:80>
DocumentRoot "C:/xampp/htdocs/some/directory/wordpress"
ServerName subdomain.customdomain.com:80
ServerAlias subdomain.customdomain.com:80
</VirtualHost>
<VirtualHost www.somedomain.com:80>
DocumentRoot "C:/xampp/some/directory2/wordpress"
ServerName www.somedomain.com:80
ServerAlias somedomain.com:80
</VirtualHost>
The configuration which fixed it:
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot "C:/xampp/htdocs/"
</VirtualHost>
<VirtualHost *:80>
ServerName subdomain.customdomain.com:80
ServerAlias subdomain.customdomain.com:80
DocumentRoot "C:/xampp/htdocs/some/directory/wordpress"
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp/some/directory2/wordpress"
ServerName www.somedomain.com:80
ServerAlias somedomain.com:80
</VirtualHost>

Using apache proxypass to redirect to /blog (wordpress)

I'm running a ReactJS app at https://www.hackachieve.com with the following structure:
Port 80/443: Front-end - ReactJS SPA
Port: 8000 - Back-end - django rest framework API
I've installed wordpress properly at /var/www/html and I'm trying to redirect the user from /blog to it.
The issue is that my proxy pass is not working. What happens when the user tries to reach https://www.hackachieve.com/blog is that its redirected back to the main page /. I've found a 301 redirect by inspecting the devtools.
/etc/apache2/sites-available/000-default.conf
<VirtualHost *:80>
ServerName hackachieve.com
ServerAlias www.hackachieve.com
ServerAdmin joaopaulofurtado#live.com
DocumentRoot /var/www/hackachieve-frontend
ProxyPreserveHost On
ProxyPass / http://localhost:5000/
ProxyPassReverse / http://localhost:5000/
RewriteEngine on
RewriteCond %{SERVER_NAME} =hackachieve.com [OR]
RewriteCond %{SERVER_NAME} =www.hackachieve.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
<VirtualHost *:443>
ServerName hackachieve.com
ServerAlias www.hackachieve.com
ServerAdmin joaopaulofurtado#live.com
DocumentRoot /var/www/hackachieve-frontend
ProxyPreserveHost On
ProxyPass / http://localhost:5000/
ProxyPassReverse / http://localhost:5000/
ErrorLog ${APACHE_LOG_DIR}/error-frontend.log
CustomLog ${APACHE_LOG_DIR}/access-frontend.log combined
RewriteEngine off
RewriteCond %{SERVER_NAME} =www.hackachieve.com [OR]
RewriteCond %{SERVER_NAME} =hackachieve.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
SSLEngine on
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/hackachieve.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/hackachieve.com/privkey.pem
</VirtualHost>
<VirtualHost *:8000>
ServerName hackachieve.com
ServerAlias www.hackachieve.com
ServerAdmin joaopaulofurtado#live.com
DocumentRoot /var/www/hackachieve-backend
ErrorLog ${APACHE_LOG_DIR}/error-backend.log
CustomLog ${APACHE_LOG_DIR}/access-backend.log combined
Alias /static /var/www/hackachieve-backend/static
<Directory /var/www/hackachieve-backend/static>
Require all granted
</Directory>
<Directory /var/www/hackachieve-backend/hackachieve>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIPassAuthorization On
WSGIDaemonProcess hackachieve python-home=/var/www/hackachieve-backend/venv python-path=/var/www/hackachieve-backend
WSGIProcessGroup hackachieve
WSGIScriptAlias / /var/www/hackachieve-backend/hackachieve/wsgi.py
SSLEngine on
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/hackachieve.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/hackachieve.com/privkey.pem
</VirtualHost>
I expect that when the user reaches https://www.hackachieve.com/blog he gets redirected to my Wordpress blog.
I don't want to ReactJS to handle this route

Symfony2 on ubuntu virtual host debug toolbar not found

I just installed LAMP on Ubuntu 14.04 LTS and created virtual host for Symfony project. I didn't change anything in the Symfony project yet but already as I try to load AcmeDemoBundle I get error An error occured while loading the web debug toolbar (404: Not found). Do you want to open profiler?
I did some research but all I found is to do something with .htaccess file which didn't work. I have some suspicions that it might be my virtual host conf file in /etc/apache2/sites-enabled/ the content of that file is:
<VirtualHost *:80>
ServerAdmin admin#localhost
ServerName registration.dev
ServerAlias www.registration.dev
DocumentRoot /var/www/registration/web/
DirectoryIndex app_dev.php
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
I had the same issue. Here a working file for your /etc/apache2/sites-enabled/
<VirtualHost *:80>
ServerName test.dev
DocumentRoot /var/www/html/test_symfony/web/
DirectoryIndex app_dev.php
<Directory "/var/www/html/test_symfony/web/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
Order allow,deny
allow from all
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /app_dev.php [QSA,L]
</IfModule>
</Directory>
The following url: http://test.dev/home will direct you to the home page without the debug toolbar. To make sure you got the tool bar specify the app_dev.php : http://test.dev/app_dev.php/home
hope it helps

htaccess redirect 2 wordpress installations

tried almost anything but i cannot get it to work
I have wordpress installation on my root folder and another installation on a subdirectory.
I have been trying to use mod_rewrite to divert all traffic coming to a sub domain to the sub directory where the other installation is.
basically i want to divert traffic coming from ads.mydomain.com to www.mydomain.com/ads (without redirecting and changing the url)
I have been using this rewrite rule
RewriteEngine On
Options Indexes FollowSymlinks Multiviews
RewriteCond %{REQUEST_URI} !^/ads/
RewriteCond %{HTTP_HOST} ^(.+)\.mydomain\.com
RewriteCond %{HTTP_HOST} !^www\.mydomain\.com
RewriteRule ^(.*)$ /ads/$1 [L]
it is working fine except that calling ads.mydomain.com/wp-admin redirects me to the main domain (www.mydomain.com/wp-admin) ...
what is wrong here ?
solved using
<VirtualHost *:80>
ServerName ads.domainname.com
ServerAlias www.ads.domainname.com
DocumentRoot /opt/bitnami/apps/wordpress/htdocs/ads
</VirtualHost>
<VirtualHost *:80>
ServerName domainname.com
ServerAlias domainname.com
ServerAlias www.domainname.com
DocumentRoot /opt/bitnami/apps/wordpress/htdocs
</VirtualHost>
on httpd.conf

Resources