{"id":20469083,"url":"https://github.com/ghosts6/v2ray_openvpn_setup","last_synced_at":"2026-04-09T21:04:04.714Z","repository":{"id":225518620,"uuid":"765389519","full_name":"Ghosts6/v2ray_openvpn_setup","owner":"Ghosts6","description":"in this repo we will setup v2ray server , openvpn server and Squid on linux machine(debian)","archived":false,"fork":false,"pushed_at":"2024-03-14T10:50:30.000Z","size":177,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-05T13:22:12.387Z","etag":null,"topics":["apache","bash","linux","nginx","open-vpn","squid","v2ray"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Ghosts6.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-02-29T20:32:11.000Z","updated_at":"2024-09-14T07:59:08.000Z","dependencies_parsed_at":"2024-03-13T14:54:08.594Z","dependency_job_id":null,"html_url":"https://github.com/Ghosts6/v2ray_openvpn_setup","commit_stats":null,"previous_names":["ghosts6/v2ray_openvpn_setup"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Ghosts6/v2ray_openvpn_setup","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ghosts6%2Fv2ray_openvpn_setup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ghosts6%2Fv2ray_openvpn_setup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ghosts6%2Fv2ray_openvpn_setup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ghosts6%2Fv2ray_openvpn_setup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ghosts6","download_url":"https://codeload.github.com/Ghosts6/v2ray_openvpn_setup/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ghosts6%2Fv2ray_openvpn_setup/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265738459,"owners_count":23820162,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apache","bash","linux","nginx","open-vpn","squid","v2ray"],"created_at":"2024-11-15T14:07:54.782Z","updated_at":"2026-04-09T21:04:04.621Z","avatar_url":"https://github.com/Ghosts6.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"![baner](https://github.com/Ghosts6/Local-website/blob/main/img/Baner.png)\n\n# 🌎v2ray,openvpn\u0026squid:\n\nThis repo include bash files to setup and manage service like v2ray and openvpn \nin this repo we place two setup method and some scripts which you can use them for service\nmanagement,also you can use squid.sh to setup proxy server.\n\n\n\n# 📖usage:\n\nTo using this files, clone the repository using the command: git clone https://github.com/Ghosts6/v2ray_openvpn_setup.git. Ensure executable permissions by running chmod +x filename on the relevant file. Depending on your requirements, execute the desired file by running ./filename. This sequence allows seamless access and execution of the provided files from the repository.\n\n```bash\nchmod +x start.sh stop.sh setup.sh status.sh optimize.sh manual_setup.sh\n./example.sh\n```\n\n# 📱setup.sh: \n\nWith setup.sh, you can easily configure V2Ray, OpenVPN, or both at same time. The script automates the preparation of requirements, configures the necessary firewall rules during setup, and setup will be end by entering some  input such as domain, preferred services, and more, streamlining the service setup process.\n\nsetup.sh:\n```bash\n#!/bin/bash\n\necho \"Updating software...\"\nsudo apt-get update \u0026\u0026 sudo apt-get upgrade -y \u0026\u0026 sudo apt-get autoremove -y\n\necho \"Enabling IP forwarding...\"\nsudo sysctl -w net.ipv4.ip_forward=1\nsudo sysctl -p\n\necho \"Installing firewall...\"\nsudo apt-get install ufw\n\necho \"Writing firewall rules and enabling firewall....\"\nsudo ufw allow ssh\nsudo ufw allow http\nsudo ufw allow https\nsudo ufw allow 1000/tcp\nsudo ufw allow 443/tcp\nsudo ufw allow 1194/udp\n\nsudo ufw enable\n\necho \"Which service do you like to install?\"\necho \"1. v2ray\"\necho \"2. openvpnserver\"\necho \"3. both\"\n\nread -p \"Enter the number corresponding to your choice: \" choice\n\ncase $choice in\n    1)\n        echo \"Installing v2ray...\"\n        sudo apt-get install nginx -y\n        sudo apt-get install wget\n\n        read -p \"Please enter your domain (example.com): \" domain\n        sudo sed -i \"s/server_name _;/server_name $domain;/g\" /etc/nginx/sites-available/default\n        systemctl restart nginx\n        snap install core\n        snap install --classic certbot\n        ln -s /snap/bin/certbot /usr/bin/certbot\n        echo \"nginx configuration:\"\n        certbot --nginx   \n        echo \"v2ray setup...\"\n        wget --no-check-certificate https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh\n        bash install-release.sh\n        sudo apt-get install uuid -y\n        uuid=$(uuid -v 4)\n        hex_number=$(openssl rand -hex 4)\n        config_file=\"/usr/local/etc/v2ray/config.json\"\n        echo \"{\n          \\\"log\\\": {\n            \\\"loglevel\\\": \\\"warning\\\",\n            \\\"access\\\": \\\"/var/log/v2ray/access.log\\\",\n            \\\"error\\\": \\\"/var/log/v2ray/error.log\\\"\n          },\n          \\\"inbounds\\\": [{\n            \\\"port\\\": 10000,\n            \\\"protocol\\\": \\\"vmess\\\",\n            \\\"settings\\\": {\n              \\\"clients\\\": [\n                {\n                  \\\"id\\\": \\\"$uuid\\\",\n                  \\\"level\\\": 1,\n                  \\\"alterId\\\": 4\n                }\n              ]\n            },\n            \\\"streamSettings\\\": {\n              \\\"network\\\": \\\"ws\\\",\n              \\\"wsSettings\\\": {\n                \\\"path\\\": \\\"$hex_number\\\"\n              }\n            }\n          }],\n          \\\"outbounds\\\": [{\n            \\\"protocol\\\": \\\"socks\\\",\n            \\\"settings\\\": {\n              \\\"servers\\\": [{\n                \\\"address\\\": \\\"127.0.0.1\\\",\n                \\\"port\\\": 9050,\n                \\\"auth\\\": \\\"noauth\\\"\n              }]\n            }\n          },{\n            \\\"protocol\\\": \\\"blackhole\\\",\n            \\\"settings\\\": {},\n            \\\"tag\\\": \\\"blocked\\\"\n          }],\n          \\\"routing\\\": {\n            \\\"rules\\\": [\n              {\n                \\\"type\\\": \\\"field\\\",\n                \\\"ip\\\": [\\\"geoip:private\\\"],\n                \\\"outboundTag\\\": \\\"blocked\\\"\n              }\n            ]\n          }\n        }\" | sudo tee \"$config_file\" \u003e /dev/null\n\n        # nginx config     \n        cat \u003c\u003cEOL | sudo tee -a /etc/nginx/sites-available/default \u003e /dev/null\nlocation /144c0889 {\n    proxy_redirect off;\n    proxy_pass http://127.0.0.1:10000;\n    proxy_http_version 1.1;\n    proxy_set_header Upgrade \\$http_upgrade;\n    proxy_set_header Connection \"upgrade\";\n    proxy_set_header Host \\$http_host;\n    # Show real IP if you enable V2Ray access log\n    proxy_set_header X-Real-IP \\$remote_addr;\n    proxy_set_header X-Forwarded-For \\$proxy_add_x_forwarded_for;\n}\nEOL\n        systemctl enable v2ray\n        systemctl start v2ray\n        ;;\n\n    2)\n        echo \"Installing openvpnserver...\"\n        echo \"Your IP is ....\"\n        sudo apt-get install curl \u0026\u0026 sudo apt-get install wget\n        curl ifconfig.me || wget -qO- ifconfig.me\n        wget https://git.io/vpn -O openvpn-install.sh\n        sudo chmod +x openvpn-install.sh\n        echo \"Please fill in data based on your need...\"\n        sudo bash openvpn-install.sh\n        sudo systemctl start openvpn-server@server.service\n\n        read -p \"Do you want to create a new client for OpenVPN? (y/n): \" answer_openvpn\n        if [[ \"$answer_openvpn\" == \"y\" || \"$answer_openvpn\" == \"Y\" ]]; then\n            sudo bash openvpn-install.sh\n        else\n            echo \"OpenVPN installation completed.\"\n        fi\n        ;;\n    3)\n        echo \"Installing both v2ray and openvpnserver...\"\n        # Install v2ray (case 1)\n        echo \"Installing v2ray...\"\n        sudo apt-get install nginx -y\n        sudo apt-get install wget\n\n        read -p \"Please enter your domain (example.com): \" domain\n        sudo sed -i \"s/server_name _;/server_name $domain;/g\" /etc/nginx/sites-available/default\n        systemctl restart nginx\n        snap install core\n        snap install --classic certbot\n        ln -s /snap/bin/certbot /usr/bin/certbot\n        echo \"nginx configuration:\"\n        certbot --nginx    \n        echo \"v2ray setup...\"\n        wget --no-check-certificate https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh\n        bash install-release.sh\n        sudo apt-get install uuid -y\n        uuid=$(uuid -v 4)\n        hex_number=$(openssl rand -hex 4)\n        config_file=\"/usr/local/etc/v2ray/config.json\"\n        echo \"{\n          \\\"log\\\": {\n            \\\"loglevel\\\": \\\"warning\\\",\n            \\\"access\\\": \\\"/var/log/v2ray/access.log\\\",\n            \\\"error\\\": \\\"/var/log/v2ray/error.log\\\"\n          },\n          \\\"inbounds\\\": [{\n            \\\"port\\\": 10000,\n            \\\"protocol\\\": \\\"vmess\\\",\n            \\\"settings\\\": {\n              \\\"clients\\\": [\n                {\n                  \\\"id\\\": \\\"$uuid\\\",\n                  \\\"level\\\": 1,\n                  \\\"alterId\\\": 4\n                }\n              ]\n            },\n            \\\"streamSettings\\\": {\n              \\\"network\\\": \\\"ws\\\",\n              \\\"wsSettings\\\": {\n                \\\"path\\\": \\\"$hex_number\\\"\n              }\n            }\n          }],\n          \\\"outbounds\\\": [{\n            \\\"protocol\\\": \\\"socks\\\",\n            \\\"settings\\\": {\n              \\\"servers\\\": [{\n                \\\"address\\\": \\\"127.0.0.1\\\",\n                \\\"port\\\": 9050,\n                \\\"auth\\\": \\\"noauth\\\"\n              }]\n            }\n          },{\n            \\\"protocol\\\": \\\"blackhole\\\",\n            \\\"settings\\\": {},\n            \\\"tag\\\": \\\"blocked\\\"\n          }],\n          \\\"routing\\\": {\n            \\\"rules\\\": [\n              {\n                \\\"type\\\": \\\"field\\\",\n                \\\"ip\\\": [\\\"geoip:private\\\"],\n                \\\"outboundTag\\\": \\\"blocked\\\"\n              }\n            ]\n          }\n        }\" | sudo tee \"$config_file\" \u003e /dev/null\n\n        # nginx config     \n        cat \u003c\u003cEOL | sudo tee -a /etc/nginx/sites-available/default \u003e /dev/null\nlocation /144c0889 {\n    proxy_redirect off;\n    proxy_pass http://127.0.0.1:10000;\n    proxy_http_version 1.1;\n    proxy_set_header Upgrade \\$http_upgrade;\n    proxy_set_header Connection \"upgrade\";\n    proxy_set_header Host \\$http_host;\n    # Show real IP if you enable V2Ray access log\n    proxy_set_header X-Real-IP \\$remote_addr;\n    proxy_set_header X-Forwarded-For \\$proxy_add_x_forwarded_for;\n}\nEOL\n        systemctl enable v2ray\n        systemctl start v2ray\n\n        echo \"Installing openvpnserver...\"\n        echo \"Your IP is ....\"\n        sudo apt-get install curl \u0026\u0026 sudo apt-get install wget\n        curl ifconfig.me || wget -qO- ifconfig.me\n        wget https://git.io/vpn -O openvpn-install.sh\n        sudo chmod +x openvpn-install.sh\n        echo \"Please fill in data based on your need...\"\n        sudo bash openvpn-install.sh\n        sudo systemctl start openvpn-server@server.service\n\n        read -p \"Do you want to create a new client for OpenVPN? (y/n): \" answer_openvpn\n        if [[ \"$answer_openvpn\" == \"y\" || \"$answer_openvpn\" == \"Y\" ]]; then\n            sudo bash openvpn-install.sh\n        else\n            echo \"OpenVPN installation completed.\"\n        fi\n        ;;\n    *)\n        echo \"Invalid choice. Exiting...\"\n        exit 1\n        ;;\nesac\n\necho \"Installation completed.\"\n\n```\n# 🖥️manual_setup.sh:\n\nFor pepole who seek configurability and accessibility, our manual_setup.sh script allows you to customize your services. Simply run\n./manual_setup.sh to take full control of the configuration process\n\nmanual setup:\n```bash\n#!/bin/bash\n\necho \"Updating software...\"\nsudo apt-get update \u0026\u0026 sudo apt-get upgrade -y \u0026\u0026 sudo apt-get autoremove -y\n\necho \"Installing packages...\"\nsudo apt install -y openvpn v2ray squid\n\necho \"OpenVPN setup: Editing config file...\"\nsudo nano /etc/openvpn/server.conf\n\necho \"Generate encryption keys...\"\nsudo openvpn --genkey --secret /etc/openvpn/ta.key\nsudo openvpn --genkey --secret /etc/openvpn/ta.key\n\necho \"Starting and enabling OpenVPN...\"\nsudo systemctl start openvpn@server \u0026\u0026 sudo systemctl enable openvpn@server\n\necho \"Configuring IP forwarding...\"\nsudo sysctl -w net.ipv4.ip_forward=1\nsudo sysctl -p\n\necho \"Adjusting Firewall Settings for OpenVPN...\"\nsudo ufw allow 1194/udp\nsudo ufw reload\n\necho \"V2Ray setup: Editing config file...\"\nsudo nano /etc/v2ray/config.json\n\necho \"Starting and enabling V2Ray...\"\nsudo systemctl start v2ray \u0026\u0026 sudo systemctl enable v2ray\n\necho \"Adjusting Firewall Settings for V2Ray...\"\nsudo ufw allow 12345\nsudo ufw reload\n\necho \"Script execution completed.\"\n```\n\n# 📲squid\n\nProxy server ,for this purpose we use squid service to run over proxy server and for this work we can use squid.sh which will install requirment and setup proxy server and confige it, also with help of this script there is no need to config fire\nwall other feature include automatic configuration and creating block list. squid.sh\n\n```bash\n#!/bin/bash\n\necho \"update and upgrade...\"\nsudo apt-get update \nsudo apt-get upgrade \n\necho \"installing squid...\"\nsudo apt-get install squid\nsudo systemctl enable squid\n\necho \"configuretion...\"\nread -p \"Enter port[3218]\" port\nif [ -z \"$port\" ]; then\n    port=\"3218\"\nfi\n\nsudo sed -i \"s/http_port 3128/http_port $port transparent/\" /etc/squid/squid.conf\nsudo sed -i \"s/http_access deny all/http_access allow all/\" /etc/squid/squid.conf\n\necho \"config firewall...\"\nsudo ufw allow $port\nsudo ufw reload\nsudo ufw status\n\necho \"starting service...\"\nsudo systemctl restart squid\nsudo systemctl status squid\n\necho \"create user...\"\nsudo apt-get install apache2-utils -y\nsudo touch /etc/squid/passwd\nsudo chown proxy: /etc/squid/passwd\n\nread -p \"Enter username:\" user\nsudo htpasswd /etc/squid/passwd $user\n\n# Adding lines for basic authentication\necho \"auth_param basic program /usr/lib64/squid/basic_ncsa_auth /etc/squid/passwd\" | sudo tee -a /etc/squid/squid.conf\necho \"auth_param basic children 5\" | sudo tee -a /etc/squid/squid.conf\necho \"auth_param basic realm Squid Basic Authentication\" | sudo tee -a /etc/squid/squid.conf\necho \"auth_param basic credentialsttl 2 hours\" | sudo tee -a /etc/squid/squid.conf\necho \"acl auth_users proxy_auth REQUIRED\" | sudo tee -a /etc/squid/squid.conf\n\nread -p \"installtion finshed,do you want create website block list(y/n)?\" choice\n\nif [[ \"$choice\" == 'y' || \"$choice\" == 'Y' ]]; then\n    read -p \"Enter the number of websites you want to block (default value = 10): \" range\n\n    if [ -z \"$range\" ]; then\n        range=10\n    fi\n\n    array_name=\"block$range\"\n    declare -a \"$array_name\"\n\n    echo \"Hint ! enter dot(.) befor start of url for example(.yahoo.com) \"\n\n    # Get input for the array\n    for ((i=0; i\u003c$range; i++)); do\n    read -p \"Enter website URL for ${array_name}[$i]: \" website\n    eval \"${array_name}[$i]=$website\" \n    done\n\n    # Write array members to the file\n    for ((i=0; i\u003c$range; i++)); do\n        echo \"${array_name}[$i]\" | sudo tee -a /etc/squid/blocked.acl\n    done\n\n    echo \"acl blocked_websites dstdomain \\\"/etc/squid/blocked.acl\\\"\" | sudo tee -a /etc/squid/squid.conf\n    echo \"http_access deny blocked_websites\" | sudo tee -a /etc/squid/squid.conf\n\n    sudo systemctl restart squid\n    sudo systemctl status squid\n\n    echo \"end of program\"\n\nelse\n    echo \"End of program.\"\nfi\n```\n\n# 🚀scripts:\n\nWe offer a suite of bash files to streamline service management. Use start.sh to initiate and enable services, stop.sh to halt services, status.sh to check service status, and optimize.sh to enhance performance. The optimization script updates packages, cleans cache, optimizes ports, and restarts services for an efficient system\n\n# 💻services:\n\nWhen initiating services using the provided bash file, the selection of services and methods determines their launch configuration. If opting for the setup file, V2Ray starts on port 10000 with the configuration file at /usr/local/etc/v2ray/config.json, while Nginx begins on port 443, using the configuration file at /etc/nginx/sites-available/default. Opting for OpenVPN defaults to port 1194, with the option to customize during setup. The protocol, either UDP or TCP, can also be specified, with the configuration file located at /etc/openvpn/server/server.conf. For manual setup, users have full control over configurations, but it's crucial to configure the firewall settings post-setup.\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghosts6%2Fv2ray_openvpn_setup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fghosts6%2Fv2ray_openvpn_setup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghosts6%2Fv2ray_openvpn_setup/lists"}