{"id":791,"date":"2025-01-15T11:40:18","date_gmt":"2025-01-15T11:40:18","guid":{"rendered":"https:\/\/blog.eu.enginyr.ing\/?p=791"},"modified":"2025-01-15T11:40:18","modified_gmt":"2025-01-15T11:40:18","slug":"how-to-use-enginyrings-nginx-with-pagespeed-docker-image-on-your-vps","status":"publish","type":"post","link":"https:\/\/www.serverspan.com\/en\/blog\/how-to-use-enginyrings-nginx-with-pagespeed-docker-image-on-your-vps\/","title":{"rendered":"How to Use ENGINYRING\u2019s NGINX with PageSpeed Docker Image on Your VPS"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">ENGINYRING is proud to offer its optimized NGINX with PageSpeed Docker image, designed for enhancing website performance. This tutorial will guide you through deploying and using this image on your Virtual Private Server (VPS). Please note that Docker requires a KVM-based VPS; LXC-based servers are incompatible.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why Choose ENGINYRING\u2019s NGINX with PageSpeed?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">PageSpeed, integrated into NGINX, automatically optimizes web content, reducing load times and improving user experience. ENGINYRING\u2019s Docker image provides:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Pre-configured NGINX 1.27.3 with PageSpeed module.<\/li>\n\n\n\n<li>Optimized for fast deployment.<\/li>\n\n\n\n<li>Lightweight and secure.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Benefits of Using PageSpeed<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Improved Page Load Times<\/strong>: Minifies CSS, JavaScript, and HTML, reducing page size.<\/li>\n\n\n\n<li><strong>Better SEO Rankings<\/strong>: Faster websites rank higher in search engine results.<\/li>\n\n\n\n<li><strong>Enhanced User Experience<\/strong>: Provides a smoother and more responsive browsing experience.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>A KVM-based VPS with Docker installed. You can explore <a href=\"https:\/\/www.enginyring.com\/en\/virtual-servers\">ENGINYRING\u2019s VPS plans<\/a>.<\/li>\n\n\n\n<li>Basic knowledge of Linux command line.<\/li>\n\n\n\n<li>Sudo or root access.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Step 1: Pull the Docker Image<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Log in to your server and pull the Docker image:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker pull enginyring\/nginx-pagespeed:bookworm<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This command downloads the latest version of ENGINYRING\u2019s optimized Docker image.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 2: Run the Docker Container<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Run the container with the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker run -d \\\n  --name nginx-pagespeed \\\n  -p 80:80 \\\n  -p 443:443 \\\n  enginyring\/nginx-pagespeed:bookworm<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This will bind your VPS\u2019s ports 80 and 443 to the container, making your optimized web server accessible.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Customizing the Run Command<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">You can add environment variables or mount volumes for more control. For example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker run -d \\\n  --name nginx-pagespeed \\\n  -p 80:80 \\\n  -p 443:443 \\\n  -v \/path\/to\/your\/config:\/etc\/nginx\/conf.d \\\n  enginyring\/nginx-pagespeed:bookworm<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 3: Verify PageSpeed Module<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To confirm PageSpeed is working, visit your site and inspect the response headers. Use the following command to check headers:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>curl -I http:\/\/your-server-ip<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You should see the <code>X-Page-Speed<\/code> header:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>X-Page-Speed: 1.14.36.1-0<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If this header is present, the PageSpeed module is active and optimizing your content.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 4: Configure NGINX<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To customize your NGINX setup, edit the configuration files inside the container. Access the container shell:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker exec -it nginx-pagespeed \/bin\/bash<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Navigate to the configuration directory:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd \/etc\/nginx<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Edit the configuration files using a text editor like <code>nano<\/code> or <code>vi<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>nano \/etc\/nginx\/conf.d\/default.conf<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">After making changes, reload NGINX:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>nginx -s reload<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Common Configuration Adjustments<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Enabling Cache<\/strong>: Adjust <code>pagespeed<\/code> cache settings to suit your website\u2019s needs.<\/li>\n\n\n\n<li><strong>Custom Compression Levels<\/strong>: Fine-tune gzip settings for optimal performance.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Step 5: Enable HTTPS<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">For a secure setup, use Let\u2019s Encrypt to enable HTTPS. You can integrate a certificate by:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Installing Certbot: <code>apt update &amp;&amp; apt install certbot<\/code><\/li>\n\n\n\n<li>Running Certbot inside the container: <code>certbot certonly --webroot -w \/usr\/share\/nginx\/html -d yourdomain.com<\/code><\/li>\n\n\n\n<li>Updating your NGINX configuration to use the certificate. Example:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>server {\n    listen 443 ssl;\n    server_name yourdomain.com;\n\n    ssl_certificate \/etc\/letsencrypt\/live\/yourdomain.com\/fullchain.pem;\n    ssl_certificate_key \/etc\/letsencrypt\/live\/yourdomain.com\/privkey.pem;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Restart NGINX to apply the changes:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>nginx -s reload<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 6: Monitor and Optimize<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Monitoring Performance<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Use tools like <code>htop<\/code> or <code>docker stats<\/code> to monitor resource usage:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker stats nginx-pagespeed<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Analyzing Logs<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Review NGINX logs to identify performance bottlenecks:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker logs nginx-pagespeed<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Fine-Tuning PageSpeed<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Experiment with different PageSpeed filters to maximize performance. Example filters include:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>extend_cache<\/code> for better caching.<\/li>\n\n\n\n<li><code>collapse_whitespace<\/code> to reduce HTML size.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Troubleshooting<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Common Issues<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Ports Already in Use<\/strong><br>Ensure no other services are occupying ports 80 or 443:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>   sudo lsof -i :80\n   sudo lsof -i :443<\/code><\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>Docker Permission Issues<\/strong><br>Run Docker commands with <code>sudo<\/code> or add your user to the <code>docker<\/code> group:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>   sudo usermod -aG docker yourusername<\/code><\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>Configuration Errors<\/strong><br>Check NGINX logs for errors:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>   docker logs nginx-pagespeed<\/code><\/pre>\n\n\n\n<ol start=\"4\" class=\"wp-block-list\">\n<li><strong>LXC Compatibility<\/strong><br>Remember, LXC-based servers cannot run Docker. Switch to a KVM-based VPS if needed.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Deploying ENGINYRING\u2019s NGINX with PageSpeed Docker image is straightforward and delivers significant performance improvements. Start optimizing your websites today with <a href=\"https:\/\/www.enginyring.com\/en\/virtual-servers\">ENGINYRING VPS plans<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>ENGINYRING is proud to offer its optimized NGINX with PageSpeed Docker image, designed for enhancing website performance. This tutorial will guide you through deploying and using this image on your Virtual Private Server (VPS). Please note that Docker requires a KVM-based VPS; LXC-based servers are incompatible. Why Choose ENGINYRING\u2019s NGINX with PageSpeed? PageSpeed, integrated into [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":792,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,12],"tags":[4079,4083,4072,3713,4076,4087,4073,4070,4077,4088,4086,4078,4084,4081,4082,4075,4080,4074,4071,4085],"class_list":["post-791","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","category-virtual-servers","tag-docker-nginx-kvm","tag-docker-nginx-pagespeed-setup","tag-enginyring-nginx","tag-enginyring-vps-hosting","tag-kvm-server-docker","tag-nginx-docker-hub","tag-nginx-docker-tutorial","tag-nginx-pagespeed-docker","tag-nginx-pagespeed-https","tag-nginx-pagespeed-image-tutorial","tag-nginx-pagespeed-lxc-limitation","tag-nginx-pagespeed-seo","tag-nginx-pagespeed-ssl","tag-nginx-performance-docker","tag-nginx-tutorial-docker","tag-optimized-nginx-pagespeed","tag-pagespeed-docker-container","tag-pagespeed-vps-setup","tag-vps-nginx-pagespeed","tag-vps-web-server-optimization"],"_links":{"self":[{"href":"https:\/\/www.serverspan.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/791","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.serverspan.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.serverspan.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.serverspan.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.serverspan.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=791"}],"version-history":[{"count":0,"href":"https:\/\/www.serverspan.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/791\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.serverspan.com\/blog\/index.php?rest_route=\/wp\/v2\/media\/792"}],"wp:attachment":[{"href":"https:\/\/www.serverspan.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=791"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.serverspan.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=791"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.serverspan.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=791"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}