Menu
ChaoTic
  • Home
  • APEX
  • PL/SQL
  • Oralce DB
  • JavaScript
  • OCI
  • C#
  • Linux
  • Privacy Policy
ChaoTic

Config Nginx as Static file server

Posted on December 15, 2022January 25, 2023
   server {
         listen 80;
         server_name static.chaoyu.nl;
         return 301 https://$server_name$request_uri;
   }
   server {
        listen       443 ssl;
        ssl_certificate "/sslcerts/certificate.crt";
        ssl_certificate_key "/sslcerts/certificate.key";
        ssl_session_cache shared:SSL:1m;
        ssl_session_timeout  10m;
        ssl_ciphers PROFILE=SYSTEM;
        ssl_prefer_server_ciphers on;

        server_name  static.chaoyu.nl
        root  /usr/share/nginx/;
        add_header Access-Control-Allow-Origin *;

        location /{
            include /etc/nginx/mime.types;
        }
        location /static-dev {
            include /etc/nginx/mime.types;
            alias  /usr/share/nginx/static/app_name1;
        }
        location /static-acc {
            include /etc/nginx/mime.types;
            alias  /usr/share/nginx/static/app_name2;

        }
        location /static-docker {
            include /etc/nginx/mime.types;
            alias  /usr/share/nginx/static/app_name3;
        }
   }

Config Linux user / groups to allow filezillar connection with key files

sudo groupadd sftpusergroup
sudo useradd mysftpuser

add user to group

sudo usermod -a -G examplegroup exampleusername

Give mysftpuser a password

sudo passwd mysftpuser
sudo nano /etc/ssh/sshd_config

find PasswordAuthentication no and change no to yes for now.

restart sshd

sudo systemctl restart sshd.service
#login with newly created user 
ssh mysftpuser@your_server_ip
#enter pwd
#create .ssh folder
mkdir .ssh
#create authorized_keys file
nano authorized_keys
# put your public key here 
# check .ssh permission and authorized_keys permission
# they must match the below pic

Here is a handy web app to calculate from drwx to number

chmod 700 .ssh/
.ssh folder permission (700)
chmod 600 .ssh/authorized_keys
authorized_kyes permission (600)

Once file/folder permission is set correctly, we need to disable password authentication

sudo nano /etc/ssh/sshd_config
#find PasswordAuthentication yes and change to no
sudo systemctl restart sshd.service

Go to /usr/share/nginx with your opc/ or any user has root rights

# create new static folder and assign the group to sftpusergroup , which is mysftpuser's group. 
# this is needed if you want to write / upload js, images, css to this static folder via filezillar 
sudo mkdir static
sudo chgrp sftpusergroup static/ -R

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • OCI Operations Professional Learning Notes
  • Tortoise Git Icon overlay not working…. (how to fix)
  • How to Export Oracle Data pump from OCI Autonomous database
  • Nginx Configuration for Custom ORDs with APEX features Google Authentication
  • Config Nginx as Static file server

Categories

  • APEX
  • C#
  • JavaScript
  • Linux
  • OCI
  • Oralce DB
  • PL/SQL
  • Uncategorized
©2023 ChaoTic | Powered by SuperbThemes & WordPress
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
Cookie SettingsAccept All
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT
Scroll Up