Absolutely! You are using XAMPP on Ubuntu (so, Apache from XAMPP, but on Linux), with:
- Laravel at port 80 (your main site, e.g.
yourdomain.com
)
- Traccar at port 8082 (backend)
- Goal:
All requests to traccar.motoshare.in
(over HTTPS) should proxy to Traccar on port 8082.
- **Both run on the same server (single IP).
Here’s an exact, copy-paste solution for XAMPP + Ubuntu:
1. Enable Apache Modules
Open a terminal and run:
sudo /opt/lampp/bin/apachectl -M | grep proxy
If you don’t see these, enable them:
sudo /opt/lampp/bin/apachectl -k stop
sudo /opt/lampp/bin/apachectl -k start
sudo ln -s /opt/lampp/etc/extra/httpd-ssl.conf /opt/lampp/etc/httpd-ssl.conf
# Edit /opt/lampp/etc/httpd.conf:
sudo nano /opt/lampp/etc/httpd.conf
# Ensure these lines are present (add if not):
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule ssl_module modules/mod_ssl.so
LoadModule headers_module modules/mod_headers.so
LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so
# Save and close (Ctrl+O, Enter, Ctrl+X)
Restart XAMPP Apache:
sudo /opt/lampp/lampp restart
2. Get SSL Certificate for traccar.motoshare.in
(A) Let’s Encrypt (Recommended)
First, install Certbot:
sudo apt update
sudo apt install certbot
Stop Apache (to free up port 80):
sudo /opt/lampp/lampp stopapache
Get the SSL certificate:
sudo certbot certonly --standalone -d traccar.motoshare.in
- Certificates will be in
/etc/letsencrypt/live/traccar.motoshare.in/
Copy the files for XAMPP Apache:
sudo cp /etc/letsencrypt/live/traccar.motoshare.in/fullchain.pem /opt/lampp/etc/ssl.crt/traccar.motoshare.in.crt
sudo cp /etc/letsencrypt/live/traccar.motoshare.in/privkey.pem /opt/lampp/etc/ssl.key/traccar.motoshare.in.key
Start Apache again:
sudo /opt/lampp/lampp startapache
(B) Self-Signed (for dev/testing only)
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
-keyout /opt/lampp/etc/ssl.key/traccar.motoshare.in.key \
-out /opt/lampp/etc/ssl.crt/traccar.motoshare.in.crt
3. Configure Apache VirtualHost for traccar.motoshare.in
Edit /opt/lampp/etc/extra/httpd-vhosts.conf
Add this block at the end:
# HTTP: Redirect to HTTPS
<VirtualHost *:80>
ServerName traccar.motoshare.in
Redirect permanent / https://traccar.motoshare.in/
</VirtualHost>
# HTTPS: Proxy to Traccar
<VirtualHost *:443>
ServerName traccar.motoshare.in
SSLEngine on
SSLCertificateFile "/opt/lampp/etc/ssl.crt/traccar.motoshare.in.crt"
SSLCertificateKeyFile "/opt/lampp/etc/ssl.key/traccar.motoshare.in.key"
# Security Headers
Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"
Header always set X-Frame-Options DENY
Header always set X-Content-Type-Options nosniff
ProxyPreserveHost On
ProxyRequests Off
ProxyPass / http://localhost:8082/
ProxyPassReverse / http://localhost:8082/
# For WebSocket support (Traccar live)
ProxyPass /api/socket ws://localhost:8082/api/socket
ProxyPassReverse /api/socket ws://localhost:8082/api/socket
ProxyTimeout 120
ProxyBadHeader Ignore
ErrorLog "logs/traccar_ssl_error.log"
CustomLog "logs/traccar_ssl_access.log" combined
</VirtualHost>
Note:
- Adjust paths if you put the certs elsewhere.
- For Laravel/main site, make sure its VirtualHost does NOT conflict with this one.
4. (Optional) Add to /etc/hosts (for local-only testing)
sudo nano /etc/hosts
Add:
127.0.0.1 traccar.motoshare.in
5. Restart XAMPP Apache
sudo /opt/lampp/lampp restart
6. Test
Quick Checklist
| What? | File/Command |
| --------------------------- | --------------------------------------------- |
| Apache conf | /opt/lampp/etc/extra/httpd-vhosts.conf
|
| SSL Cert/Key | /opt/lampp/etc/ssl.crt/
, /ssl.key/
|
| Enable modules | Edit /opt/lampp/etc/httpd.conf
|
| Restart XAMPP Apache | sudo /opt/lampp/lampp restart
|
| Certbot SSL (Let's Encrypt) | /etc/letsencrypt/live/traccar.motoshare.in/
|
If you want to add a Laravel vhost as well (for your main site):
<VirtualHost *:80>
ServerName yourdomain.com
DocumentRoot "/opt/lampp/htdocs/your-laravel-public"
<Directory "/opt/lampp/htdocs/your-laravel-public">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Troubleshooting
- If Apache fails to start:
Check /opt/lampp/logs/error_log
for SSL or proxy errors.
- Certbot fails on port 80:
Make sure nothing else (including XAMPP Apache) is running on 80 before running Certbot standalone.
Summary
- All requests to
traccar.motoshare.in
(HTTPS) are proxied to Traccar on localhost:8082
.
- SSL is set up in XAMPP’s Apache with Let’s Encrypt or self-signed certs.
- Laravel continues to run at its own vhost.
If you need any part explained in more detail (like WebSocket proxying, multi-site with Laravel, etc.), just ask!