Advertisement
Guest User

Untitled

a guest
Jan 20th, 2025
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.83 KB | None | 0 0
  1. <VirtualHost *:443>
  2. ServerName lemmy.makearmy.io
  3. ServerAdmin [email protected]
  4. ErrorLog "/usr/local/apache2/logs/ssl-error_log"
  5. CustomLog "/usr/local/apache2/logs/ssl-access_log" common
  6. CustomLog "/usr/local/apache2/logs/ssl_request_log" \
  7. "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
  8.  
  9. LogLevel warn
  10.  
  11. SSLEngine on
  12. #SSLProtocol all -SSLv2
  13. SSLProtocol -all +TLSv1.2 +TLSv1.3
  14. SSLCipherSuite HIGH:!MEDIUM:!LOW:!aNULL:!NULL:!SHA
  15. #SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW
  16.  
  17. SSLCertificateFile "/root/.acme.sh/lemmy.makearmy.io_ecc/lemmy.makearmy.io.cer"
  18. SSLCertificateKeyFile "/root/.acme.sh/lemmy.makearmy.io_ecc/lemmy.makearmy.io.key"
  19. SSLCertificateChainFile "/root/.acme.sh/lemmy.makearmy.io_ecc/fullchain.cer"
  20.  
  21. SSLHonorCipherOrder on
  22. SSLCompression off
  23. SSLSessionTickets off
  24.  
  25. Protocols h2 http/1.1
  26.  
  27. <FilesMatch "\.(cgi|shtml|phtml|php)$">
  28. SSLOptions +StdEnvVars
  29. </FilesMatch>
  30.  
  31. <Directory /usr/local/apache2/secure/makearmy.io.lemmy>
  32. Options -Indexes +FollowSymLinks +MultiViews
  33. AllowOverride All
  34. Require all granted
  35. </Directory>
  36. <FilesMatch \.php$>
  37. # Apache 2.4.10+ can proxy to unix socket
  38. SetHandler "proxy:unix:///run/php83-fpm.sock|fcgi://localhost/"
  39. </FilesMatch>
  40.  
  41. <Directory "/usr/local/apache2/cgi-bin">
  42. SSLOptions +StdEnvVars
  43. </Directory>
  44.  
  45.  
  46.  
  47.  
  48. # Add compression for some text-based resources
  49. # AddOutputFilterByType DEFLATE text/css
  50. # AddOutputFilterByType DEFLATE application/javascript
  51. # AddOutputFilterByType DEFLATE image/svg+xml
  52.  
  53. # Add headers
  54. Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains"
  55. Header always set X-Frame-Options SAMEORIGIN
  56. Header always set X-Content-Type-Options nosniff
  57. Header always set X-XSS-Protection "1; mode=block"
  58. ProxyPreserveHost On
  59. ProxyAddHeaders On
  60.  
  61. # Don't proxy LetsEncrypt's ACME challenge
  62. ProxyPass /.well-known/acme-challenge/ !
  63. <Directory /opt/lemmy/lemmy-ui/dist/.well-known/acme-challenge>
  64. Require all granted
  65. AllowOverride none
  66. Options -Indexes +FollowSymLinks
  67. </Directory>
  68.  
  69. # Don't proxy static files, serve them directly instead
  70. ProxyPassMatch ^/(assets|js|styles|service-worker.js) !
  71.  
  72. DocumentRoot /opt/lemmy/lemmy-ui/dist
  73.  
  74. <Directory /opt/lemmy/lemmy-ui/dist>
  75. Require all granted
  76. </Directory>
  77.  
  78. # Proxy API calls
  79. ProxyPassMatch ^/(api|pictrs|feeds|nodeinfo|\.well-known)/(.*)$ ws://127.0.0.1:8536/$1/$2
  80.  
  81. # ProxyPassReverse doesn't like regexps, so we have to manually specify every location
  82. ProxyPassReverse /api/ ws://127.0.0.1:8536/api/
  83. ProxyPassReverse /pictrs/ ws://127.0.0.1:8536/pictrs/
  84. ProxyPassReverse /feeds/ ws://127.0.0.1:8536/feeds/
  85. ProxyPassReverse /nodeinfo/ ws://127.0.0.1:8536/nodeinfo/
  86. ProxyPassReverse /.well-known/ ws://127.0.0.1:8536/.well-known/
  87.  
  88. # Proxy the frontend
  89. ProxyPass / http://127.0.0.1:1234/
  90. ProxyPassReverse / http://127.0.0.1:1234/
  91.  
  92. # Correctly proxy websocket traffic
  93. RewriteEngine On
  94. RewriteCond %{HTTP:Upgrade} websocket [NC]
  95. RewriteRule .* ws://127.0.0.1:8536%{REQUEST_URI} [P]
  96.  
  97. # Proxy POST and JSON requests directly to the backend
  98. RewriteCond %{HTTP_ACCEPT} "=application/activity+json" [NC,OR]
  99. RewriteCond %{HTTP_ACCEPT} '=application/ld+json; profile="https://www.w3.org/ns/activitystreams"' [NC,OR]
  100. RewriteCond %{REQUEST_METHOD} ^POST [NC]
  101. RewriteRule .* ws://127.0.0.1:8536%{REQUEST_URI} [P]
  102.  
  103. </VirtualHost>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement