I’m trying to put production shopware on a server and add a domain to it. The domain added to nginx, and here is my configuration.
server {
server_name shopware.mydomain.com;
location / {
proxy_pass http://localhost:8085;
proxy_hide_header X-Frame-Options;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_hide_header Content-Security-Policy;
proxy_hide_header X-Content-Type-Options;
proxy_hide_header Referrer-Policy;
}
add_header Access-Control-Allow-Origin *;
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/shopware.domain.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/shopware.domain.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 = shopware.mydomain.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name shopware.mydomain.com;
return 404; # managed by Certbot
}
Where let’s say "mydomain" is just my domain. Here is my /etc/hosts
127.0.0.1 localhost
91.205.75.138 199047.webh.me 199047
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
127.0.0.1 mydomain.com shopware.mydomain.com
I installed Shopware, but when I go into /admin, I get a JavaScript error caused by shopware trying to download js from http://localhost:8085 instead of the domain it is assigned. How do I get this to work properly?
2
Answers
For those who will have problems in the future. Shopware by default provides a docker image that includes nginx and php. In my case, there was an external nginx that handled the domain and SSL certificate, while this nginx inside the docker image overwrote my requests. So I split these images into smaller ones as follows:
Dockerfile for php-fpm
You should change the
APP_URL
variable in your.env
file, which is located in the root directory of your Shopware 6 instance.