I have a domain on AWS EC2 instance with SSL that is served at https://example.com
.
The only job for this domain is to proxy traffic from the domain to my home PC which serves a Laravel app. They are connected via WireGuard tunnel.
nginx is used both on the EC2 instance and locally.
This is my config in the EC2 instance:
server {
server_name example.com www.example.com;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host-Real-IP $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://10.10.10.1:80; # WireGuard IP
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = www.example.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = example.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
server_name example.com www.example.com;
listen 80;
return 404; # managed by Certbot
}
Now when I develop locally the app is not using SSL so the URLs there aren't secured. For example the login page action is http://192.168.100.100/login
and not https.
But then when I try to login from the domain and not locally at https://example.com/login
, it doesn't work. Nothing happens it just refreshes the page.
So when I set the form action to https
, then it works from the domain, but then locally it doesn't work (locally I get 419 page expired, maybe because my app expects the CSRF token but there is issue with the conflicting HTTP/HTTPS?)
How should I make it work in this case? Do you want me to also post my local nginx config as well?
Can I make my app also work locally with SSL? So serving it like https://192.168.100.100
? (but then how do I do it)