Hot answers tagged

4

How are you currently handling the redirect? I assume since you only have the 1 Nginx server block for the site and letting Magento handle it the redirect using the Base Url? Adding a server block like so and removing the example.com server name from the existing block should handle redirecting with the exact same request URI (not appending /). server { ...


4

At present I see the expires is set to -1 The Expires header you see is client-side. Browsers should not cache things like product pages, etc. which is why the default Magento VCL sets it to -1 in vcl_deliver procedure. The vcl_deliver is what you use in Varnish for controlling the output to the clients (e.g. browsers). How long Varnish will cache things ...


4

Please use to below command sudo update-alternatives --config php After run above command select the PHP version that you need to use. Press to keep the current choice[*], or type selection number: For example 2 After switching below command used to restart the PHP and Nginx server. sudo service nginx restart sudo service php7.1-fpm or php7.2-fpm ...


3

I'm not an nginx expert, but Servers for Hackers has provided a superb walkthrough of nesting one PHP application within another. I've broken down their instructions in a way that might help, or at least point you in the right direction. I assume here that you're serving Magento from pub as Magento recommends, so that your directory structure looks like /var/...


2

For apache you can use the following - for example just put it into your .htaccess file in the document root directory: RewriteCond %{REQUEST_URI} ^/products.*$ RewriteCond %{QUERY_STRING} ^.*test_category=99.*$ RewriteRule .* /testproducts? [R=301,NC,L] This does a 301 redirect. If you just want to serve the content (i.e. internal rediect so the client ...


2

I guess the 302 redirect comes from Magento, because you call without the configured host in your url. Try something like this in your nginx: if ($host != 'www.newsite.com'){ return 301 https://www.newsite.com$request_uri }


2

I think you have tried to find the solution from the google but my advise is to check Magento DevDocs first always where you can find everything which can be done in Magento 2. Here, I have attached the link where Magento DevDocs provided the steps to setup the multiple websites or stores. Kindly refer this link: https://devdocs.magento.com/guides/v2.3/...


2

Nginx Not pass Access-Control-Allow-Origin by using below module it will pass the header in API It can update from Store >> Config >> General >> WEb Change * to any url you want to access https://github.com/splashlab/magento-2-cors-requests


1

you see this config part: upstream fastcgi_backend { server unix:/run/php-fpm/php-fpm.sock; } this is where your php-fpm is listening. please check your php-fpm config, it must be the same socket path, with correct user read permissions. or change it to ip:port - 127.0.0.1:9000


1

502 error nginx upstream not available. you need to check nginx proxy / php block in configuration. nginx php upstream wrong port defined, socket permissions, upstream not running, firewall blocking, error log you can see in nginx config: https://docs.nginx.com/nginx/admin-guide/monitoring/logging/#error_log https://nginx.org/en/docs/ngx_core_module.html?...


1

In your nginx configuration file (nginx.conf) check who is the user. In your nginx.conf the user directive should at the top. Then check if the directory /var/www/www-root/data/www/mysite.com/ belong to that user. Now lets say your user in nginx is www-data and the files in /var/www/www-root/data/www/mysite.com/ belongs to root. You should run a command to ...


1

your development must be separated from live. it is better for security and maintenance. just copy your magento installation to another account / home folder. copy nginx config, update root, domain and base url. in varnish you need to add either one: full domain bypass: if (req.http.host ~ "^dev\.example\.com$") { return (pass); } or parameter ?developer ...


1

This have been done in the same wrong way by many folks: NGINX config with pub as webroot (great) web URL includes pub in URLs (bad) To explain it simply why it doesn't work for you: NGINX root is pub directory, so anything that starts with / is already in pub. When you put links that include pub, they are trying to load /path/to/pub/pub/some/file (which ...


1

Is it not loading because of a 404 ? Did you check if the file generation to pub/static works, means is it an issue with the loading, or already the generation ? Is your magento installation in production mode, and if yes, did you regenerate the static content using php bin/magento setup:static-content:deploy? Did you check the file and folder permissions ...


1

Magento has configurations for both Apache and Nginx ready to use for production. The reason why Magento team offer these configurations out of the box is for security reasons. If you check the folder update you will notice that there are these files/folders app -> folder dev -> folder pub -> folder vart -> folder .gitignore -> file .htaccess -> file ...


1

your Plesk nginx config have: location / { proxy_pass https://my.ip.address:7081; .... so it works as proxy. you need to change Plesk settings to disable proxy and apache: https://support.plesk.com/hc/en-us/articles/213924385-How-to-switch-a-domain-to-nginx-only-hosting-in-Plesk then you get another nginx config. but... I really ...


1

You may try to create a PHP script as described below and after that instead calling Magento 2 API directly from the angular app (xyz.test.com), call this PHP script with some parameter. In the PHP script, you can add Access-Control-Allow-Origin to the header. It is not the best solution but works. step 1) Create a PHP file under Magento 2 root Please ...


1

you have typo in headers: Header set Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS' always" Header set Access-Control-Allow-Headers "Host, Content-Type, Origin, Accept" probably must be like: Header always set Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS" Header set Access-Control-Allow-Headers "Host, Content-Type, Origin, ...


1

you need to use varnish port 6081 to proxy https location / { proxy_pass http://127.0.0.1:6081; user -> nginx:80 -> nginx:443 -> varnish:6081 -> nginx:8080


1

I have added the code here. Please check and compare with your code. And do correction if need. \app\code\MyCompany\ExampleAdminNewPage\registration.php <?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, 'MyCompany_ExampleAdminNewPage', __DIR__ ); ...


1

Have you considered editing index.php to catch php server host and then loading store view based on this. So no nginx rules. Hardcoded logic within magento itself. We had a problem install where we just couldn't multisite working and this worked for us. So like this https://community.magento.com/t5/Magento-2-x-Admin-Configuration/Magento-2-Multi-website-...


1

to help you debug this, you can add this php file for example, headers.php: <?php foreach($_SERVER as $key_name => $key_value) { print $key_name . " = <font style='color: rgb(0,0,255);'>" . $key_value . "</font><br/>"; } ?> where you can see all the headers. make sure you proxy pass correct header: proxy_set_header X-...


1

Try this, You can add it in the /etc/nginx/nginx.conf file add the below code to it server { listen 80 listen 443; server_name blog.club.in; location = / { return 301 http://domain.com/blog; } } NOTE : Make sure you choose to move this temporarily or permanent. Temporary in the sense use 302 instead of 301 Visit this link for more information ...


1

You probably want to just use an nginx temporary redirect instead. server { . . . server_name ch-de.main.local; rewrite ^/(.*)$ http://de.main.local/$1 redirect; . . . } server { . . . server_name de.main.local; . . . } I wouldnt bother with htaccess if you have nginx.


1

sudo a2dismod php7.0 sudo a2enmod php7.2 sudo systemctl restart apache2 Reference: Link


1

For Nginx, we simply need to update the PHP-FPM socket in its configuration file. But before that make sure that the PHP-FPM is installed for your version and is running as a service. Take a backup of the default configuration file and then open it up in your favourite text editor. $ cp /etc/nginx/sites-available/default /etc/nginx/sites-available/default....


1

For each redirect, you can add the following line to your nginx configuration, inside of the location / block (first): rewrite /old/url.html /new/url.html I hope this will help


1

I followed the above (moving the /static block inside the /pub block) but it didn't work for me. In the end, what did the trick was then adding in a new block for /static as follows : location /static/ { if (!-f $request_filename) { rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last; } } Note that is subtly different to the ...


1

edit /app/etc/env.php file 'session' => [ 'save' => 'files', 'save_path' => 'D:\wamp64\www\projectName\var\session' // put full directory path ], it worked fine!


1

Add below session code php.ini file at end of file session.save_handler = files ;session.save_path = "/tmp" to session.save_handler = files session.save_path = "var/www/magento2/var/session" Edited php.env file: 'session' => array ( 'save' => 'files', ), to 'session' => array ( 'save' => 'files', 'save_path' => ...


Only top voted, non community-wiki answers of a minimum length are eligible