Advertisement
Justman10000

Apache2 Config

Apr 3rd, 2023 (edited)
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. // Replace yourdomain.tld with your domain
  2. // Replace port with the port
  3. // Only http
  4. <VirtualHost *:80>
  5. ServerName yourdomain.tld
  6. DocumentRoot /home/web
  7.  
  8. ErrorLog ${APACHE_LOG_DIR}/error.log
  9. CustomLog ${APACHE_LOG_DIR}/access.log combined
  10.  
  11. # If you do not use a proxy
  12. <Directory /home/web>
  13. AllowOverride all
  14. Require all granted
  15. </Directory>
  16.  
  17. # If you use a proxy
  18. ProxyPreserveHost On
  19.  
  20. ProxyPass / http://127.0.0.1:port/
  21. ProxyPassReverse / http://127.0.0.1:port/
  22. # If the application use websockets
  23. RewriteCond %{HTTP:Upgrade} =websocket
  24. RewriteRule /(.*) ws://localhost:port/$1 [P,L]
  25. RewriteCond %{HTTP:Upgrade} !=websocket
  26. RewriteRule /(.*) http://localhost:port/$1 [P,L]
  27. </VirtualHost>
  28.  
  29. // With SSL (https)
  30. <VirtualHost *:80>
  31. ServerName yourdomain.tld
  32.  
  33. ErrorLog ${APACHE_LOG_DIR}/error.log
  34. CustomLog ${APACHE_LOG_DIR}/access.log combined
  35.  
  36. RewriteEngine on
  37. RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
  38. </VirtualHost>
  39.  
  40. <VirtualHost *:443>
  41. ServerName yourdomain.tld
  42. DocumentRoot /home/web
  43.  
  44. ErrorLog ${APACHE_LOG_DIR}/error.log
  45. CustomLog ${APACHE_LOG_DIR}/access.log combined
  46.  
  47. SSLEngine On
  48. SSLCertificateFile /etc/letsencrypt/live/yourdomain.tld/cert.pem
  49. SSLCertificateKeyFile /etc/letsencrypt/live/yourdomain.tld/privkey.pem
  50. SSLCertificateChainFile /etc/letsencrypt/live/yourdomain.tld/fullchain.pem
  51.  
  52. # If you do not use a proxy
  53. <Directory /home/web>
  54. AllowOverride all
  55. Require all granted
  56. </Directory>
  57.  
  58. # If you use a proxy
  59. ProxyPreserveHost On
  60.  
  61. ProxyPass / http://127.0.0.1:port/
  62. ProxyPassReverse / http://127.0.0.1:port/
  63. # If the application use websockets
  64. RewriteCond %{HTTP:Upgrade} =websocket
  65. RewriteRule /(.*) ws://localhost:port/$1 [P,L]
  66. RewriteCond %{HTTP:Upgrade} !=websocket
  67. RewriteRule /(.*) http://localhost:port/$1 [P,L]
  68. </VirtualHost>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement